pan3793 commented on code in PR #36995:
URL: https://github.com/apache/spark/pull/36995#discussion_r916672796


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DistributionAndOrderingUtils.scala:
##########
@@ -53,16 +63,27 @@ object DistributionAndOrderingUtils {
         query
       }
 
-      val ordering = toCatalystOrdering(write.requiredOrdering, query)
+      val ordering = toCatalystOrdering(write.requiredOrdering, query, 
funCatalogOpt)
       val queryWithDistributionAndOrdering = if (ordering.nonEmpty) {
-        Sort(ordering, global = false, queryWithDistribution)
+        Sort(
+          ordering.map(ur => 
resolveTransformExpression(ur).asInstanceOf[SortOrder]),
+          global = false,
+          queryWithDistribution)
       } else {
         queryWithDistribution
       }
 
-      queryWithDistributionAndOrdering
+      // Apply typeCoercionRules
+      SimpleAnalyzer.execute(queryWithDistributionAndOrdering)
 
     case _ =>
       query
   }
+
+  def resolveTransformExpression(expr: Expression): Expression = 
expr.transform {
+    case TransformExpression(scalarFunc: ScalarFunction[_], arguments, 
Some(numBuckets)) =>

Review Comment:
   `TransformExpression` is introduced in SPARK-37377(#35657), to check input 
partition compatibility, it's constructed in `V2ScanPartitioningAndOrdering`



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

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to