-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-34639][SQL] Always remove unnecessary Alias in Analyzer.resolveExpression #31758
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import scala.collection.JavaConverters._ | |
import org.apache.spark.annotation.Stable | ||
import org.apache.spark.api.python.PythonEvalType | ||
import org.apache.spark.broadcast.Broadcast | ||
import org.apache.spark.sql.catalyst.analysis.{Star, UnresolvedAlias, UnresolvedAttribute, UnresolvedFunction} | ||
import org.apache.spark.sql.catalyst.analysis.{Star, UnresolvedAlias, UnresolvedFunction} | ||
import org.apache.spark.sql.catalyst.encoders.encoderFor | ||
import org.apache.spark.sql.catalyst.expressions._ | ||
import org.apache.spark.sql.catalyst.expressions.aggregate._ | ||
|
@@ -80,11 +80,7 @@ class RelationalGroupedDataset protected[sql]( | |
} | ||
} | ||
|
||
// Wrap UnresolvedAttribute with UnresolvedAlias, as when we resolve UnresolvedAttribute, we | ||
// will remove intermediate Alias for ExtractValue chain, and we need to alias it again to | ||
// make it a NamedExpression. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is wrong as we don't remove top-level aliases for aggregate expressions. It causes problems as it wraps For nested field Here I simply remove this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this code is pretty old, 2015. I saw There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only for |
||
private[this] def alias(expr: Expression): NamedExpression = expr match { | ||
case u: UnresolvedAttribute => UnresolvedAlias(u) | ||
case expr: NamedExpression => expr | ||
case a: AggregateExpression if a.aggregateFunction.isInstanceOf[TypedAggregateExpression] => | ||
UnresolvedAlias(a, Some(Column.generateAlias)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not related to this PR, but a small followup from #31728 (comment)