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/04/29 09:42:56 UTC

[GitHub] [spark] ulysses-you commented on a change in pull request #32391: [SPARK-35264][SQL] Support AQE side broadcastJoin threshold

ulysses-you commented on a change in pull request #32391:
URL: https://github.com/apache/spark/pull/32391#discussion_r622892555



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/DynamicJoinSelection.scala
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.execution.adaptive
+
+import org.apache.spark.sql.catalyst.optimizer.{BuildLeft, BuildRight, JoinSelectionHelper}
+import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys
+import org.apache.spark.sql.catalyst.plans.JoinType
+import org.apache.spark.sql.catalyst.plans.logical.{BROADCAST, HintInfo, JoinHint, LogicalPlan, NO_BROADCAST_HASH, SHUFFLE_HASH}
+import org.apache.spark.sql.catalyst.rules.Rule
+
+/**
+ * The main idea here is that make join config isolation between normal planner and aqe planner
+ * which shared the same code path.
+ * In order to achieve this we use a specific join hint in advance during AQE framework and then
+ * at JoinSelection side it will take and follow the inserted hint.
+ *
+ * For now we only support select strategy for equi join, and follow this order:
+ *   1. mark join as broadcast hash join if possible
+ *   2. mark join as shuffled hash join if possible
+ *
+ * Note that, we don't override join strategy if user specifies a join hint.
+ */
+object DynamicJoinSelection extends Rule[LogicalPlan] with JoinSelectionHelper {
+  final override val isAdaptive: Boolean = true
+
+  private def insertJoinHint(

Review comment:
       @cloud-fan  That might work but I want to explain some reason of adding this rule at AQE optimizer side. Currently it looks like we follow the `JoinSelection` logic but it may be broken. Then we can easily add other join selection in future.
   
   Let's assume if we have an another config like `spark.sql.adaptive.shuffledHashJoinBuildSideThreshold`, then we can add the check in this rule so that we can pick the SMJ instead of SHJ if it's partition size over the threshold.




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