SNOW-2081762: No session in _do_register_udf
Please answer these questions before submitting your issue. Thanks!
- What version of Python are you using?
Python 3.10.11
-
What operating system and processor architecture are you using?
macOS-15.4.1-arm64-arm-64bit
-
What are the component versions in the environment (
pip freeze)?annotated-types==0.7.0 asn1crypto==1.5.1 atpublic==5.1 backports.tarfile==1.2.0 boto3==1.37.20 botocore==1.37.20 certifi==2025.1.31 cffi==1.17.1 cfgv==3.4.0 charset-normalizer==3.4.1 click==8.1.8 cloudpickle==2.2.1 colorama==0.4.3 configobj==5.0.9 coverage==7.8.0 cryptography==44.0.1 distlib==0.3.9 exceptiongroup==1.2.2 factory_boy==3.3.3 Faker==37.0.0 filelock==3.17.0 gitdb==4.0.12 GitPython==3.1.44 identify==2.6.8 idna==3.10 importlib_metadata==8.6.1 iniconfig==2.0.0 jaraco.classes==3.4.0 jaraco.context==6.0.1 jaraco.functools==4.1.0 Jinja2==3.1.6 jmespath==1.0.1 keyring==23.1.0 keyrings.alt==5.0.2 markdown-it-py==3.0.0 MarkupSafe==3.0.2 mdurl==0.1.2 more-itertools==10.6.0 nodeenv==1.9.1 packaging==24.2 platformdirs==4.3.6 pluggy==1.5.0 pre_commit==4.1.0 prompt_toolkit==3.0.50 protobuf==5.29.3 pyasn1==0.6.1 pycparser==2.22 pycryptodomex==3.21.0 pydantic==2.11.3 pydantic_core==2.33.1 pydevd-pycharm==251.21418.69 Pygments==2.19.1 PyJWT==2.10.1 pyOpenSSL==24.3.0 pytest==8.3.5 pytest-randomly==3.16.0 pytest_httpserver==1.1.3 python-dateutil==2.9.0.post0 pytz==2025.1 PyYAML==6.0.2 requests==2.32.3 requirements-parser==0.11.0 rich==14.0.0 rsa==4.9.1 s3transfer==0.11.4 shellingham==1.5.4 six==1.17.0 smmap==5.0.2 -e git+ssh://[email protected]/snowflakedb/snowflake-cli.git@dc4eceb8bf34b141c879565304fb13ba0ab99e74#egg=snowflake_cli snowflake-connector-python==3.15.0 snowflake-snowpark-python==1.31.0 snowflake.core==1.3.0 sortedcontainers==2.4.0 sqlparse==0.4.2 syrupy==4.9.1 tomli==2.2.1 tomlkit==0.13.2 typer==0.15.2 types-setuptools==75.8.0.20250210 typing-inspection==0.4.0 typing_extensions==4.12.2 tzdata==2025.1 tzlocal==5.3 urllib3==2.3.0 virtualenv==20.29.2 wcwidth==0.2.13 Werkzeug==3.1.3 zipp==3.21.0
-
What did you do?
We want to update snowpark-python lib from 1.25.0 to 1.31.0 but one of our Native App test is failing. We use the following functions: https://github.com/snowflakedb/snowflake-cli/blob/main/tests_e2e/test_data/nativeapp/python/cli_gen/accepted.py https://github.com/snowflakedb/snowflake-cli/blob/main/tests_e2e/test_data/nativeapp/python/cli_gen/udtf/custom_udtf.py
For both we got: 'NoneType' object has no attribute '_ast_batch'
-
What did you expect to see?
No error. In 1.26.0 or 1.27.0 you introduced _emit_ast with default True value, and if it is True you do
self._session._ast_batch.bind()where in our case the session is None.We are not able to update the lib because of that.
-
Can you set logging to DEBUG and collect the logs?
import logging for logger_name in ('snowflake.snowpark', 'snowflake.connector'): logger = logging.getLogger(logger_name) logger.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s')) logger.addHandler(ch)
Hello @sfc-gh-astus ,
Thanks for raising the issue, I can see the code changes between 1.25.0 and 1.31.0 for files for _emit_ast
https://github.com/snowflakedb/snowpark-python/blob/v1.25.0/src/snowflake/snowpark/column.py https://github.com/snowflakedb/snowpark-python/blob/06709ec09fc6a535765c9d35925e7102d2b0cea8/src/snowflake/snowpark/column.py#L331
Could you provide the sample application if possible.
Regards, Sujan
Hi @sfc-gh-sghosh,
Thanks for reply, it is not that simple to provide example app, one of our Native App test fails. Native App runs locally functions with @udaf/@udf decorators, and fails on line self._session._ast_batch.bind(). It is working on 1.25.0, but fails on 1.31.0. Should self._session be always not None?
Hello @sfc-gh-astus ,
Sure, please at least capture the logs with 1.25.0 and 1.31.0. We will look into it.
Regards, Sujan
Nice.