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-821644 add dataframe alias support #79

Merged
merged 7 commits into from
Jan 4, 2024
Merged

Conversation

sfc-gh-zli
Copy link
Contributor

Please answer these questions before submitting your pull requests. Thanks!

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

    Fixes #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Replace this with a short description of how your code change solves the related issue.

Pre-review checklist

(For Snowflake employees)

  • This change has passed precommit
  • I have reviewed code coverage report for my PR in (Sonarqube)

src/main/scala/com/snowflake/snowpark/Column.scala Outdated Show resolved Hide resolved
@@ -2791,7 +2808,8 @@ class DataFrame private[snowpark] (

// utils
private[snowpark] def resolve(colName: String): NamedExpression = {
val normalizedColName = quoteName(colName)
val (aliasColName, aliasOutput) = resolveAlias(colName, output)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we directly return result form resolveAlias if we can find that name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to quote the column name and check for name conflicts, so it's better to return the column name and output list.

@@ -192,6 +206,17 @@ private[snowpark] case class Sort(order: Seq[SortOrder], child: LogicalPlan) ext
Sort(order, _)
}

private[snowpark] case class DataframeAlias(alias: String, child: LogicalPlan)
extends UnaryNode {
dfAliasMap += (alias -> child.getSnowflakePlan.get.output)
Copy link
Collaborator

Choose a reason for hiding this comment

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

override lazy val dfAliasMap = child.dfAliasMap + (alias -> child.getSnowflakePlan.get.output)


addToDataframeAliasMap(left)
addToDataframeAliasMap(right)
Copy link
Collaborator

Choose a reason for hiding this comment

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

override lazy val dfAliasMap = left.dfAliasMap ++ right.dfAliasMap

Copy link
Collaborator

@sfc-gh-bli sfc-gh-bli left a comment

Choose a reason for hiding this comment

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

Approved with some comments, please merge after address those comments.

@sfc-gh-zli sfc-gh-zli enabled auto-merge (squash) January 3, 2024 23:13
@sfc-gh-zli sfc-gh-zli enabled auto-merge (squash) January 3, 2024 23:18
@sfc-gh-zli sfc-gh-zli merged commit e8a35b3 into main Jan 4, 2024
15 checks passed
@sfc-gh-zli sfc-gh-zli deleted the zli/SNOW-821644 branch January 4, 2024 00:20
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.

2 participants