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 2022/08/09 05:25:52 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #37129: [SPARK-39710][SQL] Support push local topK through outer join

cloud-fan commented on code in PR #37129:
URL: https://github.com/apache/spark/pull/37129#discussion_r940910196


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushLocalTopKThroughOuterJoin.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.catalyst.optimizer
+
+import org.apache.spark.sql.catalyst.expressions.{Literal, SortOrder}
+import org.apache.spark.sql.catalyst.planning.{ExtractEquiJoinKeys, ExtractTopK}
+import org.apache.spark.sql.catalyst.plans.{JoinType, LeftOuter, RightOuter}
+import org.apache.spark.sql.catalyst.plans.logical.{Join, LocalLimit, LogicalPlan, Project, RebalancePartitions, Repartition, RepartitionByExpression, Sort, Union}
+import org.apache.spark.sql.catalyst.rules.Rule
+import org.apache.spark.sql.catalyst.trees.TreePattern.{LIMIT, OUTER_JOIN, SORT}
+import org.apache.spark.sql.internal.SQLConf
+
+/**
+ * This rule supports push down local limit and local sort from TopK through outer join:
+ *   - for a left outer join, the references of ordering of TopK come from the left side and
+ *     the limits of TopK is smaller than left side max rows
+ *   - for a right outer join, the references of ordering of TopK come from the right side and
+ *     the limits of TopK is smaller than right side max rows
+ *
+ * Note that, this rule only push down local topK to the bottom outer join which is different with
+ * [[LimitPushDown]]. This is to avoid regression due to the overhead of local sort.

Review Comment:
   can you elaborate on how this can avoid perf regression?



-- 
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-unsubscribe@spark.apache.org

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