AngersZhuuuu opened a new pull request #30199:
URL: https://github.com/apache/spark/pull/30199


   ### What changes were proposed in this pull request?
   Nested grouping. analytics can't run but throw  ambiguous exception, This pr 
make these case throw exceptions that are easy for users to understand
   ```
   spark-sql>  select a, b, c from x group by cube(a, b) with cube;;
   20/10/30 12:20:20 ERROR SparkSQLDriver: Failed in [ select a, b, c from x 
group by cube(a, b) with cube]
   java.lang.UnsupportedOperationException
        at 
org.apache.spark.sql.catalyst.expressions.GroupingSet.dataType(grouping.scala:36)
        at 
org.apache.spark.sql.catalyst.expressions.GroupingSet.dataType$(grouping.scala:36)
        at 
org.apache.spark.sql.catalyst.expressions.Cube.dataType(grouping.scala:61)
   
   
   spark-sql> select a, b, c from x group by cube(a, b, c) grouping sets(a, b, 
(a, b));
   Error in query: unresolved operator 'GroupingSets [ArrayBuffer(a#0), 
ArrayBuffer(b#1), ArrayBuffer(a#0, b#1)], [cube(a#0, b#1, c#2)], [a#0, b#1, 
c#2];;
   'GroupingSets [ArrayBuffer(a#0), ArrayBuffer(b#1), ArrayBuffer(a#0, b#1)], 
[cube(a#0, b#1, c#2)], [a#0, b#1, c#2]
   +- SubqueryAlias spark_catalog.default.x
      +- HiveTableRelation [`default`.`x`, 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [a#0, b#1, c#2], 
Partition Cols: []]
   
   
   spark-sql>  select a, b, c from x group by a, b,  c grouping sets(a, b, 
cube(a, b));
   Error in query: unresolved operator 'GroupingSets [ArrayBuffer(a#3), 
ArrayBuffer(b#4), ArrayBuffer(cube(a#3, b#4))], [a#3, b#4, c#5], [a#3, b#4, 
c#5];;
   'GroupingSets [ArrayBuffer(a#3), ArrayBuffer(b#4), ArrayBuffer(cube(a#3, 
b#4))], [a#3, b#4, c#5], [a#3, b#4, c#5]
   +- SubqueryAlias spark_catalog.default.x
      +- HiveTableRelation [`default`.`x`, 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [a#3, b#4, c#5], 
Partition Cols: []]
   
   ```
   
   ### Why are the changes needed?
   Throw an exception that is easy for the user to understand
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Add UT


----------------------------------------------------------------
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]

Reply via email to