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

Feedback on public api #2735

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

sfc-gh-aalam
Copy link
Contributor

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-NNNNNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

Comment on lines +874 to +875
# - check isinstance(session, snowflake.snowpark.Session)
# - update kwargs["_emit_ast"] = value
Copy link
Contributor Author

@sfc-gh-aalam sfc-gh-aalam Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed we are not checking isinstance(session, Session) in all branches so this would make it more consistent

return True # noqa: B012
# session has not been created yet, do not encode AST be default.
# TODO: flip this to True when we go GA.
return False # noqa: B012
Copy link
Contributor

@sfc-gh-oplaton sfc-gh-oplaton Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're moving away from hard-coded True, the value should come from an environment variable, or some other suitable global configuration source. We don't want to be in a place where the feature is untestable while under development/opt-in mode.

Copy link
Contributor Author

@sfc-gh-aalam sfc-gh-aalam Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it not be testable if user has a session and they have oped-in such that session.ast_enabled returns true.

We reach this case when a valid session is not found. Now, default to assuming that ast is enabled but I suggest we default to assuming it is disabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much of the Snowpark public API surface is session-agnostic. Hard-coding this return value to False breaks the following valid code:

  avg_a = call_function("avg", col("a"))
  with Session.builder.config(...).create() as session:
    df = session.create_dataframe([1, 2, 3, 4], schema=["a"])
    df.select(avg_a).show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants