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/31 13:42:06 UTC

[GitHub] [spark] AngersZhuuuu commented on a change in pull request #30145: [SPARK-33233][SQL]CUBE/ROLLUP/GROUPING SETS support GROUP BY ordinal

AngersZhuuuu commented on a change in pull request #30145:
URL: https://github.com/apache/spark/pull/30145#discussion_r604908038



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/SubstituteUnresolvedOrdinals.scala
##########
@@ -27,13 +27,23 @@ import org.apache.spark.sql.types.IntegerType
  * Replaces ordinal in 'order by' or 'group by' with UnresolvedOrdinal expression.
  */
 object SubstituteUnresolvedOrdinals extends Rule[LogicalPlan] {
-  private def isIntLiteral(e: Expression) = e match {
+  private def containIntLiteral(e: Expression): Boolean = e match {
     case Literal(_, IntegerType) => true
+    case Cube(_, groupByExprs) => groupByExprs.exists(containIntLiteral)
+    case Rollup(_, groupByExprs) => groupByExprs.exists(containIntLiteral)
+    case GroupingSets(_, flatGroupingSets, groupByExprs) =>
+      flatGroupingSets.exists(containIntLiteral) || groupByExprs.exists(containIntLiteral)
     case _ => false
   }
 
+  private def resolveOrdinal(expression: Expression): Expression = expression match {

Review comment:
       > the name is weird as it returns `UnresolvedOrdinal`. how about `substituteUnresolvedOrdinal`?
   
   Done and updated some missed logic.




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