-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24424][SQL] Support ANSI-SQL compliant syntax for GROUPING SET #21813
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
Changes from 1 commit
b5ada3f
ac8f04f
7cf187d
e0c57f7
2ecf3e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -442,6 +442,9 @@ class Analyzer( | |
| child: LogicalPlan): LogicalPlan = { | ||
| val gid = AttributeReference(VirtualColumn.groupingIdName, IntegerType, false)() | ||
|
|
||
| // In case of ANSI-SQL compliant syntax for GROUPING SETS, groupByExprs is optional and | ||
| // can be null. In such case, we derive the groupByExprs from the user supplied values for | ||
| // grouping sets. | ||
| val finalGroupByExpressions = if (groupByExprs == Nil) { | ||
| selectedGroupByExprs.flatten.foldLeft(Seq.empty[Expression]) { (result, currentExpr) => | ||
|
Member
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. What if
Contributor
Author
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. @viirya No. We should be getting an error as we don't have a group by specification. I had tried this scenario against db2 to double check.
Member
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. Can we have a test case for it too?
Contributor
Author
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. @viirya Yeah.. was already adding it .. knew u would ask :-)
Member
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. @dilipbiswal Thanks! :-) |
||
| // Only unique expressions are included in the group by expressions and is determined | ||
|
|
||
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.
Shouldn't we do this in the branch of
case x: GroupingSets if x.expressions.forall(_.resolved) =>? I think thisconstructAggregatemethod is also used by other clauses likeCubeandRollup.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.
@viirya Yeah.. so for cube and rollup, we will always have groupByExprs setup right ? So i felt its better to keep the code consolidated here in this function. What do u think ?
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.
Ok. Mind to add a comment on this like
SPARK-24424: this only happens for ANSI-SQL compliant syntax for GROUPING SET?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.
@viirya Sure will do.