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-1899126: Fix malformed sql for functions that create internal alias #3136

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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-1899126

  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.

    In this PR, we do the following:

    • Add a new internal method Column._alias to mark aliases created internally by snowpark functions.
    • Add a new UnaryExpression _InternalAlias to differentiate between internal and user-created aliases.
    • Refactor the analyze method to ignore internal aliases when it is not top level expression.

@sfc-gh-aalam sfc-gh-aalam marked this pull request as ready for review March 10, 2025 16:54
@sfc-gh-aalam sfc-gh-aalam requested review from a team as code owners March 10, 2025 16:54
[Row('{"end":"1970-01-01 00:00:10.000","start":"1970-01-01 00:00:00.000"}')],
)
Utils.check_answer(
df.select(second(to_timestamp(window(df.ts, "10 seconds")["end"]))),
Copy link
Contributor

Choose a reason for hiding this comment

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

For this second example what does the final column name end up being?

@@ -592,6 +613,11 @@ def analyze(
str(expr)
) # pragma: no cover

def internal_alias_extractor(self, expr: Expression) -> Expression:
Copy link
Contributor

Choose a reason for hiding this comment

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

one last comment: can you add comment on when this function needs to called when analyzing expression to give some context to future us?

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

Successfully merging this pull request may close these issues.

3 participants