代码之家  ›  专栏  ›  技术社区  ›  jtlz2

如何解决SnowparkSQLException:。。。Snowpark python SPROC调用的函数中用户为空?

  •  1
  • jtlz2  · 技术社区  · 4 月前

    调用Snowpark注册的SPROC时,我收到以下错误:

    SnowparkSQLException: (1304): <uuid>: 100357 (P0000): <uuid>: Python Interpreter Error:
    snowflake.connector.errors.ProgrammingError: 251005: User is empty in function MY_FUNCTION with handler compute
    

    对于以下python代码和调用:

    def my_function(session: Session,
                    input_table: str,
                    limit: int) -> None:
        # Even doing nothing doesn't work!
        return
    
    sproc_my_function = my_session.sproc.register(func=my_function,
                                               name='my_function',
                                               is_permanent=True,
                                               replace=True,
                                               stage_location='@STAGE_LOC',
                                               execute_as="owner",
    
    
    input_table = 'x.y.MY_INPUT_TABLE'
    
    sproc_process_row(my_session,
                      input_table,
                      100,
                      )
    

    我在互联网上的任何地方都找不到对此异常和“用户在功能中为空”的引用,这让我怀疑这是否是某种形式的直通。我也找不到将用户传递给注册方法的方法(在设置my_session时,这已经成功完成)。

    请帮帮我!

    1 回复  |  直到 4 月前
        1
  •  1
  •   Lukasz Szozda    4 月前

    使用雪花笔记本:

    from snowflake.snowpark.session import Session
    my_session = snowflake.snowpark.context.get_active_session()
    
    def my_function(session: Session,
                    input_table: str,
                    limit: int) -> None:
        return None
    
    sproc_my_function = my_session.sproc.register(func=my_function,
                                               name='my_function',
                                               is_permanent=True,
                                               replace=True,
                                               stage_location='STAGE_LOC',
                                               execute_as="owner",
                                               packages=["snowflake-snowpark-python"])
    

    输出:

    enter image description here