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/01/27 23:30:47 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #31355: [SPARK-34255][SQL] Support partitioning with static number on required distribution and ordering on V2 write

dongjoon-hyun commented on a change in pull request #31355:
URL: https://github.com/apache/spark/pull/31355#discussion_r565709706



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DistributionAndOrderingUtils.scala
##########
@@ -32,21 +32,29 @@ object DistributionAndOrderingUtils {
     case write: RequiresDistributionAndOrdering =>
       val resolver = conf.resolver
 
-      val distribution = write.requiredDistribution match {
+      val (distribution, numPartitions) = write.requiredDistribution match {
         case d: OrderedDistribution =>
-          d.ordering.map(e => toCatalyst(e, query, resolver))
+          val dist = d.ordering.map(e => toCatalyst(e, query, resolver))
+          val numParts = d.requiredNumPartitions()
+          (dist, numParts)
         case d: ClusteredDistribution =>
-          d.clustering.map(e => toCatalyst(e, query, resolver))
+          val dist = d.clustering.map(e => toCatalyst(e, query, resolver))
+          val numParts = d.requiredNumPartitions()
+          (dist, numParts)
         case _: UnspecifiedDistribution =>
-          Array.empty[Expression]
+          (Array.empty[Expression], 0)
       }
 
       val queryWithDistribution = if (distribution.nonEmpty) {
-        val numShufflePartitions = conf.numShufflePartitions
+        val finalNumPartitions = if (numPartitions > 0) {

Review comment:
       ~Shall we keep the original variable name?~ Never mind.
   ```scala
   - val finalNumPartitions = if (numPartitions > 0) {
   + val numShufflePartitions = if (numPartitions > 0) {
   ```




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