AngersZhuuuu commented on a change in pull request #28490:
URL: https://github.com/apache/spark/pull/28490#discussion_r470660102
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1479,6 +1479,33 @@ class Analyzer(
// Skip the having clause here, this will be handled in
ResolveAggregateFunctions.
case h: UnresolvedHaving => h
+ case agg @ (_: Aggregate | _: GroupingSets) =>
+ val resolved = agg.mapExpressions(resolveExpressionTopDown(_, agg))
+ val hasStructField = resolved.expressions.exists {
+ _.collectFirst { case gsf: GetStructField => gsf }.isDefined
+ }
+ if (hasStructField) {
+ // For struct field, it will be resolve as Alias(GetStructField,
name),
+ // In Aggregate/GroupingSets this behavior will cause same struct
field
+ // in aggExprs/groupExprs/selectedGroupByExprs will be resolved
divided
+ // with different ExprId of Alias and replace failed when construct
+ // Aggregate in ResolveGroupingAnalytics, so we resolve duplicated
struct
+ // field here with same ExprId
+ val structFieldMap = mutable.Map[String, Alias]()
+ resolved.transformExpressionsDown {
Review comment:
> another concern: for `SELECT a.b, a.b FROM t GROUP BY a.b`, will we
end up with an `Aggregate` operator whose output has duplicated ExprId? It's
probably not an issue as the two output columns always have the same value.
struct.sql in UT show as `t`.`c`.`json_string`, [table].[column].[field],
so seems won't have case that same `struct.sql` mean different column?
New way in https://github.com/apache/spark/pull/28490#discussion_r470555710
only handle current node to avoid same struct.sql show different column
because of alias in different sql level.
emm, for two output `a.b`, it's hard to say which one is the one in cube?
right?, so in this case same output with duplicated exprId seems ok.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]