snowflakedb / snowflakedb/snowpark-python

SNOW-2213161: explode() with local testing in Snowpark Python fails with AttributeError

Open
#3,565 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug local testing status-triage_done
Dominant language
Python
Stars
341
Forks
155
Avg merge
4d 16h
Merged PRs (30d)
27

Description

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?

    Python 3.11.0 (main, Jun 30 2025, 10:43:55) [Clang 17.0.0 (clang-1700.0.13.5)]

  2. What are the Snowpark Python and pandas versions in the environment?

pandas==2.3.1
snowflake-snowpark-python==1.34.0

  1. What did you do?

When attempting to use explode() function in local testing, the below error is seen.

AttributeError: 'MockSelectStatement' object has no attribute 'snowflake_plan'

Here's a step by step repro -

>>> from snowflake.snowpark import Session
>>> from snowflake.snowpark.functions import explode
>>> session = Session.builder.config('local_testing', True).create()
>>> data = [
...     {
...         "foo": "bar",
...         "my_array": ["one","two"]
...     }
... ]
>>> df = session.create_dataframe(data, schema=["foo", "my_array"])
>>> df.show()
--------------------------
|"FOO"  |"MY_ARRAY"      |
--------------------------
|bar    |['one', 'two']  |
--------------------------

>>> df.select("foo", explode("my_array")).show()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ksreekandath/.pyenv/versions/case_01077035/lib/python3.11/site-packages/snowflake/snowpark/_internal/telemetry.py", line 368, in wrap
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ksreekandath/.pyenv/versions/case_01077035/lib/python3.11/site-packages/snowflake/snowpark/_internal/utils.py", line 1120, in call_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ksreekandath/.pyenv/versions/case_01077035/lib/python3.11/site-packages/snowflake/snowpark/dataframe.py", line 1634, in select
    new_cols, alias_cols = _get_cols_after_explode_join(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ksreekandath/.pyenv/versions/case_01077035/lib/python3.11/site-packages/snowflake/snowpark/table_function.py", line 327, in _get_cols_after_explode_join
    plan = select_statement.select([func.col._named()]).snowflake_plan
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MockSelectStatement' object has no attribute 'snowflake_plan'
>>> 

  1. What did you expect to see?
>>> from snowflake.snowpark import Session
from snowflake.snowpark.functions import explode
>>> session=Session.builder.config("connection_name","XTB17692").create()
>>> data = [
...     {
...         "foo": "bar",
...         "my_array": ["one","two"]
...     }
... ]
>>> df = session.create_dataframe(data, schema=["foo", "my_array"])
>>> df.show()
----------------------
|"FOO"  |"MY_ARRAY"  |
----------------------
|bar    |[           |
|       |  "one",    |
|       |  "two"     |
|       |]           |
----------------------

>>> df.select("foo", explode("my_array")).show()
-------------------
|"FOO"  |"VALUE"  |
-------------------
|bar    |"one"    |
|bar    |"two"    |
-------------------

>>> 
>>> 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.