Github user pwoody commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18542#discussion_r125840979
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileFormatWriter.scala
 ---
    @@ -116,13 +116,26 @@ object FileFormatWriter extends Logging {
         val partitionSet = AttributeSet(partitionColumns)
         val dataColumns = allColumns.filterNot(partitionSet.contains)
     
    -    val bucketIdExpression = bucketSpec.map { spec =>
    +    val bucketPartitioning = bucketSpec.map { spec =>
           val bucketColumns = spec.bucketColumnNames.map(c => 
dataColumns.find(_.name == c).get)
    +      HashPartitioning(bucketColumns, spec.numBuckets)
    +    }
    +
    +    val bucketIdExpression = bucketPartitioning.map { partitioning =>
           // Use `HashPartitioning.partitionIdExpression` as our bucket id 
expression, so that we can
           // guarantee the data distribution is same between shuffle and 
bucketed data source, which
           // enables us to only shuffle one side when join a bucketed table 
and a normal one.
    -      HashPartitioning(bucketColumns, 
spec.numBuckets).partitionIdExpression
    +      partitioning.partitionIdExpression
         }
    +
    +    // If the plan's outputPartitioning is the same as the the bucket 
spec, then each row will have
    +    // a constant bucket id. We possibly can avoid the sort altogether.
    +    val bucketSortExpression = plan.outputPartitioning match {
    +      case output: HashPartitioning =>
    +        
bucketPartitioning.filterNot(_.semanticEquals(output)).map(_.partitionIdExpression)
    --- End diff --
    
    I don't think I'm quite following. If 
`bucketPartitioning.semanticEquals(outputPartitioning)`, then they both must 
have the same `numPartitions` in their expression?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to