Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/19281#discussion_r139873547 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkPlan.scala --- @@ -396,6 +396,26 @@ abstract class SparkPlan extends QueryPlan[SparkPlan] with Logging with Serializ object SparkPlan { private[execution] val subqueryExecutionContext = ExecutionContext.fromExecutorService( ThreadUtils.newDaemonCachedThreadPool("subquery", 16)) + + /** + * Returns if the actual ordering satisfies the required ordering. + * + * Ordering A satisfies ordering B if and only if B is an equivalent of A or of A's prefix. + */ + def orderingSatisfies(actual: Seq[SortOrder], required: Seq[SortOrder]): Boolean = { + if (required.nonEmpty) { + if (required.length > actual.length) { + false + } else { + required.zip(actual).forall { + case (requiredOrder, actualOrder) => + actualOrder.satisfies(requiredOrder) + } + } + } else { + true + } --- End diff -- Please simplify it to ```Scala if (required.isEmpty) { true } else if (required.length > actual.length) { false } else { required.zip(actual).forall { case (requiredOrder, actualOrder) => actualOrder.satisfies(requiredOrder) } } ```
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org