雪花snowpark python工作表udf

问题描述 投票:0回答:1

@udf(name='a_plus_b', input_types=[IntegerType(), IntegerType()], return_type=IntegerType(), is_permanent=False, 替换=True) def a_plus_b(a: int, b: int) -> int: 返回a+b

def main(会话:snowpark.Session):

df.with_column('Somme',a_plus_b( col('a'),col('b') ) )

return df

这是我的@udf 注册中的错误。 回溯(最近一次调用最后一次):工作表,第 8 行,在 文件“snowflake/snowpark/functions.py”中,第 6693 行,在 udf session = session 或 Snowflake.snowpark.session._get_active_session() 文件“snowflake/snowpark/”中session.py”,第 179 行,在 _get_active_session 中引发 SnowparkClientExceptionMessages.SERVER_NO_DEFAULT_SESSION() Snowflake.snowpark.exceptions.SnowparkSessionException: (1403): 未找到默认会话。请在调用函数“udf”或使用装饰器“@udf”之前创建一个会话。

有人可以帮我吗。

python function snowflake-cloud-data-platform worksheet
1个回答
0
投票

def main(会话:snowpark.Session):

@udf(name='a_plus_b', input_types=[IntegerType(), IntegerType()], return_type=IntegerType(), is_permanent=False, replace=True)
def a_plus_b(a: int, b: int) -> int: return a+b

df.with_column('Somme',a_plus_b( col('a'),col('b') ) )

返回df

© www.soinside.com 2019 - 2024. All rights reserved.