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

    https://github.com/apache/spark/pull/5208#discussion_r28287120
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/Exchange.scala ---
    @@ -168,14 +190,16 @@ private[sql] case class AddExchange(sqlContext: 
SQLContext) extends Rule[SparkPl
             // At least one child does not satisfies its required data 
distribution or
             // at least one child's outputPartitioning is not compatible with 
another child's
             // outputPartitioning. In this case, we need to add Exchange 
operators.
    -        val repartitionedChildren = 
operator.requiredChildDistribution.zip(operator.children).map {
    -          case (AllTuples, child) =>
    +        val repartitionedChildren = operator.requiredChildDistribution.zip(
    +          operator.children.zip(operator.requiredChildOrdering)
    +        ).map {
    +          case (AllTuples, (child, _)) =>
                 addExchangeIfNecessary(SinglePartition, child)
    -          case (ClusteredDistribution(clustering), child) =>
    -            addExchangeIfNecessary(HashPartitioning(clustering, 
numPartitions), child)
    -          case (OrderedDistribution(ordering), child) =>
    +          case (ClusteredDistribution(clustering), (child, rowOrdering)) =>
    +            addExchangeIfNecessary(HashPartitioning(clustering, 
numPartitions), child, rowOrdering)
    +          case (OrderedDistribution(ordering), (child, _)) =>
    --- End diff --
    
    I think it is not okay to ignore the ordering here, otherwise if someone 
adds a node that requires `OrderedDistribution` and a partition ordering we 
will silently plan it wrong.  Instead (if you change the order spec back to 
`Seq[SortOrder]`) I think you can just match on `Seq()` to make sure it is 
empty.  This will ensure we throw an error below (please also update the error 
to print the ordering).


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