snowflakedb / snowflakedb/snowpark-python
SNOW-2920252: [Local Testing] Lag window function produces ValueError when partitioning by multiple columns
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 341
- Forks
- 155
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 27
Description
-
What version of Python are you using?
Python 3.9.6 (default, Oct 17 2025, 17:15:53)
[Clang 17.0.0 (clang-1700.4.4.1)] -
What are the Snowpark Python and pandas versions in the environment?
pandas==2.3.3
snowflake-snowpark-python==1.43.0 -
What did you do?
When running the script below with the lag function, local-testing produces ValueError: 10 is not in list.
This error only appears on a specific set of values as demonstrated in a script with "group_ok" and "group_error" columns. -
What did you expect to see?
When running the same snowpark code in Snowflake I get the following result:
output.csvThe code I used to run in Snowflake to verify expected behavior:
snowflake_run.sql
Potential fix
There is a similar issue raised for other window functions like this one: https://github.com/snowflakedb/snowpark-python/issues/3459 which was followed by PR: https://github.com/snowflakedb/snowpark-python/pull/3462.
But it looks like lag and lead functions have a special handling logic in file _plan.py which was not touched in this PR. The issue looks very similar though and replacing res_index with pd_index in the line below fixed the issue locally for me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.