Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1952961: Type Errors on DataFrame Functions Due to Missing Optional Type Hints #3084

Open
zaramzamzam opened this issue Feb 27, 2025 · 2 comments
Assignees
Labels
bug Something isn't working status-triage Issue is under initial triage

Comments

@zaramzamzam
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?
    Python 3.11.7

  2. What operating system and processor architecture are you using?

macOS-15.3.1-arm64-arm-64bit

  1. What are the component versions in the environment (pip freeze)?

snowflake-connector-python==3.13.2
snowflake-snowpark-python==1.28.0

  1. What did you do?

Accessing functions on a snowpark dataframe results in errors due to mishandling of types in the snowpark library.

Example:
Using type checkers (Pylance/Pyright in VS Code)
Results in error:

Argument of type "None" cannot be assigned to parameter "_ast_stmt" of type "Assign" in function "filter"
  "None" is not assignable to "Assign"Pylance[reportArgumentType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportArgumentType)

Example code:

from snowflake import snowpark
from snowflake.snowpark.functions import col

def example(session: snowpark.Session):
    session.table("example_table").where(col("col1") == "value1")
  1. What did you expect to see?

This should not result in a type error.

More information:

This seems to be introduced in snowflake-snowpark-python versions > 1.25.0 due to assigning None to arguments which are not marked as optional.

Example line

@zaramzamzam zaramzamzam added bug Something isn't working needs triage Initial RCA is required labels Feb 27, 2025
@github-actions github-actions bot changed the title Type Errors on DataFrame Functions Due to Missing Optional Type Hints SNOW-1952961: Type Errors on DataFrame Functions Due to Missing Optional Type Hints Feb 27, 2025
@jjlkant
Copy link

jjlkant commented Feb 27, 2025

I also just ran into the same issue, on e.g. session.sql() and DataFrame.with_column() calls.

A temporary workaround seems to be that pyright <= 1.1.394 is able to work with this Optional[...] missing, but the latest version rightfully throws errors.

@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Feb 28, 2025
@sfc-gh-sghosh sfc-gh-sghosh added status-triage Issue is under initial triage and removed needs triage Initial RCA is required labels Feb 28, 2025
@sfc-gh-sghosh
Copy link

Hello @zaramzamzam ,

Thanks for raising the issue, we are looking into it, will update.

Regards,
Sujan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

3 participants