You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/03 23:51:58 UTC
[GitHub] [spark] maropu commented on a change in pull request #30781: [SPARK-22748][SQL] Analyze grouping__id bug when grouping__id is used as a column reference of subquery
maropu commented on a change in pull request #30781:
URL: https://github.com/apache/spark/pull/30781#discussion_r586898670
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -2099,9 +2099,14 @@ class Analyzer(override val catalogManager: CatalogManager)
ResolvedFunc(Identifier.of(funcIdent.database.toArray, funcIdent.funcName))
case q: LogicalPlan =>
+ val isGroupingIdAllowed = q match {
+ case _: Aggregate | _: GroupingSets | _: Filter | _: Sort => true
Review comment:
It will throw an analysis exception both after/before this PR, e.g.,
```
scala> sql("select * from t3").show()
+---+---+------------+
| a| b|grouping__id|
+---+---+------------+
| 1| 2| 3|
+---+---+------------+
// with/without this PR
scala> sql("select * from t3 where grouping__id > 0").show()
org.apache.spark.sql.AnalysisException: grouping()/grouping_id() can only be used with GroupingSets/Cube/Rollup;
```
On the other hand, this PR will change behaviours other than these operators above, e.g.,
```
// The current behaviour
scala> sql("select grouping__id from t3").show()
org.apache.spark.sql.AnalysisException: grouping_id() can only be used with GroupingSets/Cube/Rollup;;
// w/ this PR
scala> sql("select grouping__id from t3").show()
+------------+
|grouping__id|
+------------+
| 3|
+------------+
```
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org