Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/7343#discussion_r34644613
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -193,16 +193,52 @@ class Analyzer(
}
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
+ case a if !a.childrenResolved => a // be sure all of the children
are resolved.
case a: Cube =>
GroupingSets(bitmasks(a), a.groupByExprs, a.child, a.aggregations)
case a: Rollup =>
GroupingSets(bitmasks(a), a.groupByExprs, a.child, a.aggregations)
case x: GroupingSets =>
val gid = AttributeReference(VirtualColumn.groupingIdName,
IntegerType, false)()
+ // We will insert another Projection if the GROUP BY keys contains
the
+ // non-attribute expressions. And the top operators can references
those
+ // expressions by its alias.
+ // e.g. SELECT key%5 as c1 FROM src GROUP BY key%5 ==>
+ // SELECT a as c1 FROM (SELECT key%5 AS a FROM src) GROUP BY a
+
+ // find all of the non-attribute expressions in the GROUP BY keys
+ val nonAttributeGroupByExpressions = new ArrayBuffer[Alias]()
+
+ // The pair of (the non-attributes expression, associated
attribute (alias))
--- End diff --
This comment is not very accurate since you also have named expressions as
keys.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]