You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "vinodkc (via GitHub)" <gi...@apache.org> on 2023/07/06 04:04:03 UTC

[GitHub] [spark] vinodkc opened a new pull request, #41875: [SPARK-44317][SQL] Use PartitionEvaluator API for ShuffledHashJoinExec

vinodkc opened a new pull request, #41875:
URL: https://github.com/apache/spark/pull/41875

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   SQL operator `ShuffledHashJoinExec` updated to use the `PartitionEvaluator` API to do execution.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   To avoid the use of lambda during distributed execution.
   Ref: SPARK-43061 for more details.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Updated 1 test case, once all the SQL operators are migrated, the flag `spark.sql.execution.useTaskEvaluator` will be enabled by default to avoid running the tests with and without this TaskEvaluator
   


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


[GitHub] [spark] viirya commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1260668576


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(
+      joinType: JoinType,
+      output: Seq[Attribute],
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): (InternalRow) => InternalRow = {
+    joinType match {
+      case LeftExistence(_) =>
+        UnsafeProjection.create(output, output)
+      case _ =>
+        // Always put the stream side on left to simplify implementation
+        // both of left and right side could be null
+        UnsafeProjection.create(
+          output, (streamedPlanOutput ++ buildPlanOutput).map(_.withNullability(true)))
+    }
+  }
+  def join(hashJoinParams: HashJoinParams): Iterator[InternalRow] = {

Review Comment:
   style: blank line between method definition.



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


[GitHub] [spark] vinodkc commented on pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on PR #41875:
URL: https://github.com/apache/spark/pull/41875#issuecomment-1625518265

   CC @cloud-fan @viirya @dongjoon-hyun @yaooqinn @beliefer @HyukjinKwon 


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


[GitHub] [spark] vinodkc commented on pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on PR #41875:
URL: https://github.com/apache/spark/pull/41875#issuecomment-1640354356

   cc @cloud-fan , @beliefer , @viirya 


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


[GitHub] [spark] cloud-fan commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1256382402


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/ShuffledHashJoinEvaluatorFactory.scala:
##########
@@ -0,0 +1,312 @@
+/*
+ * 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.joins
+
+import org.apache.spark.{PartitionEvaluator, PartitionEvaluatorFactory, TaskContext}
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression, GenericInternalRow, JoinedRow, Predicate, UnsafeProjection}
+import org.apache.spark.sql.catalyst.optimizer.{BuildLeft, BuildRight, BuildSide}
+import org.apache.spark.sql.catalyst.plans.{FullOuter, JoinType, LeftOuter, RightOuter}
+import org.apache.spark.sql.execution.RowIterator
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.util.collection.{BitSet, OpenHashSet}
+
+class ShuffledHashJoinEvaluatorFactory(
+    output: Seq[Attribute],
+    condition: Option[Expression],
+    buildPlanOutput: Seq[Attribute],
+    streamedPlanOutput: Seq[Attribute],
+    joinType: JoinType,
+    buildSide: BuildSide,
+    join: (Iterator[InternalRow], HashedRelation, SQLMetric) => Iterator[InternalRow],

Review Comment:
   is it possible to not pass a lambda?



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


[GitHub] [spark] viirya commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1262023493


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(
+      joinType: JoinType,
+      output: Seq[Attribute],
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): (InternalRow) => InternalRow = {
+    joinType match {
+      case LeftExistence(_) =>
+        UnsafeProjection.create(output, output)
+      case _ =>
+        // Always put the stream side on left to simplify implementation
+        // both of left and right side could be null
+        UnsafeProjection.create(
+          output, (streamedPlanOutput ++ buildPlanOutput).map(_.withNullability(true)))
+    }
+  }
+  def join(hashJoinParams: HashJoinParams): Iterator[InternalRow] = {
+
+    val streamedIter: Iterator[InternalRow] = hashJoinParams.streamedIter
+    val hashed: HashedRelation = hashJoinParams.hashedRelation
+    val streamedKeys: Seq[Expression] = hashJoinParams.streamedKeys
+    val streamedOutput: Seq[Attribute] = hashJoinParams.streamedOutput
+    val condition: Option[Expression] = hashJoinParams.condition
+    val joinType: JoinType = hashJoinParams.joinType
+    val buildSide: BuildSide = hashJoinParams.buildSide
+    val buildPlanOutput: Seq[Attribute] = hashJoinParams.buildPlanOutput
+    val streamedPlanOutput: Seq[Attribute] = hashJoinParams.streamedPlanOutput
+    val output: Seq[Attribute] = hashJoinParams.output
+    val numOutputRows: SQLMetric = hashJoinParams.numOutputRows
+
+    val joinedIter = joinType match {
+      case _: InnerLike =>
+        innerJoin(
+          streamedIter,
+          hashed,
+          streamedKeys,
+          streamedOutput,
+          condition,
+          joinType,
+          buildSide,
+          buildPlanOutput,
+          streamedPlanOutput)

Review Comment:
   Oh, I meant previously the join methods e.g., `innerJoin` which only needs two parameters, but now it takes many ones. Is it possible to initiates the two parameters before calling them so we can keep original signature of them (two parameters: stream iterator and hash relation)?
   
   I don't look the join methods in details, if it is impossible, it is fine.



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


[GitHub] [spark] vinodkc commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1261942668


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(
+      joinType: JoinType,
+      output: Seq[Attribute],
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): (InternalRow) => InternalRow = {
+    joinType match {
+      case LeftExistence(_) =>
+        UnsafeProjection.create(output, output)
+      case _ =>
+        // Always put the stream side on left to simplify implementation
+        // both of left and right side could be null
+        UnsafeProjection.create(
+          output, (streamedPlanOutput ++ buildPlanOutput).map(_.withNullability(true)))
+    }
+  }
+  def join(hashJoinParams: HashJoinParams): Iterator[InternalRow] = {
+
+    val streamedIter: Iterator[InternalRow] = hashJoinParams.streamedIter
+    val hashed: HashedRelation = hashJoinParams.hashedRelation
+    val streamedKeys: Seq[Expression] = hashJoinParams.streamedKeys
+    val streamedOutput: Seq[Attribute] = hashJoinParams.streamedOutput
+    val condition: Option[Expression] = hashJoinParams.condition
+    val joinType: JoinType = hashJoinParams.joinType
+    val buildSide: BuildSide = hashJoinParams.buildSide
+    val buildPlanOutput: Seq[Attribute] = hashJoinParams.buildPlanOutput
+    val streamedPlanOutput: Seq[Attribute] = hashJoinParams.streamedPlanOutput
+    val output: Seq[Attribute] = hashJoinParams.output
+    val numOutputRows: SQLMetric = hashJoinParams.numOutputRows
+
+    val joinedIter = joinType match {
+      case _: InnerLike =>
+        innerJoin(
+          streamedIter,
+          hashed,
+          streamedKeys,
+          streamedOutput,
+          condition,
+          joinType,
+          buildSide,
+          buildPlanOutput,
+          streamedPlanOutput)

Review Comment:
   @viirya, I didn't get the suggestion clearly, could you please give a bit more details?



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


[GitHub] [spark] beliefer commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1260627562


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -39,7 +39,18 @@ private[joins] case class HashedRelationInfo(
     relationTerm: String,
     keyIsUnique: Boolean,
     isEmpty: Boolean)
-
+private[joins] case class HashJoinParams(

Review Comment:
   Personally, I like observe one empty line between class declaration.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -39,7 +39,18 @@ private[joins] case class HashedRelationInfo(
     relationTerm: String,
     keyIsUnique: Boolean,
     isEmpty: Boolean)
-
+private[joins] case class HashJoinParams(
+    streamedIter: Iterator[InternalRow],
+    hashedRelation: HashedRelation,
+    condition: Option[Expression],
+    streamedKeys: Seq[Expression],
+    streamedOutput: Seq[Attribute],
+    buildPlanOutput: Seq[Attribute],
+    streamedPlanOutput: Seq[Attribute],
+    output: Seq[Attribute],
+    joinType: JoinType,
+    buildSide: BuildSide,
+    numOutputRows: SQLMetric)
 trait HashJoin extends JoinCodegenSupport {

Review Comment:
   ditto.



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


[GitHub] [spark] vinodkc commented on pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API for ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on PR #41875:
URL: https://github.com/apache/spark/pull/41875#issuecomment-1622941110

   CC @cloud-fan @viirya @dongjoon-hyun @yaooqinn @beliefer


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


[GitHub] [spark] beliefer commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1256929660


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(joinType: JoinType,
+             output: Seq[Attribute],

Review Comment:
   Please reduce the indent.



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


[GitHub] [spark] viirya commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1262791433


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(
+      joinType: JoinType,
+      output: Seq[Attribute],
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): (InternalRow) => InternalRow = {
+    joinType match {
+      case LeftExistence(_) =>
+        UnsafeProjection.create(output, output)
+      case _ =>
+        // Always put the stream side on left to simplify implementation
+        // both of left and right side could be null
+        UnsafeProjection.create(
+          output, (streamedPlanOutput ++ buildPlanOutput).map(_.withNullability(true)))
+    }
+  }
+  def join(hashJoinParams: HashJoinParams): Iterator[InternalRow] = {
+
+    val streamedIter: Iterator[InternalRow] = hashJoinParams.streamedIter
+    val hashed: HashedRelation = hashJoinParams.hashedRelation
+    val streamedKeys: Seq[Expression] = hashJoinParams.streamedKeys
+    val streamedOutput: Seq[Attribute] = hashJoinParams.streamedOutput
+    val condition: Option[Expression] = hashJoinParams.condition
+    val joinType: JoinType = hashJoinParams.joinType
+    val buildSide: BuildSide = hashJoinParams.buildSide
+    val buildPlanOutput: Seq[Attribute] = hashJoinParams.buildPlanOutput
+    val streamedPlanOutput: Seq[Attribute] = hashJoinParams.streamedPlanOutput
+    val output: Seq[Attribute] = hashJoinParams.output
+    val numOutputRows: SQLMetric = hashJoinParams.numOutputRows
+
+    val joinedIter = joinType match {
+      case _: InnerLike =>
+        innerJoin(
+          streamedIter,
+          hashed,
+          streamedKeys,
+          streamedOutput,
+          condition,
+          joinType,
+          buildSide,
+          buildPlanOutput,
+          streamedPlanOutput)

Review Comment:
   Okay, then it is fine.



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


Re: [PR] [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec
URL: https://github.com/apache/spark/pull/41875


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


[GitHub] [spark] vinodkc commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1257324222


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(joinType: JoinType,
+             output: Seq[Attribute],

Review Comment:
   Done



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


[GitHub] [spark] viirya commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1260662863


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -39,7 +39,18 @@ private[joins] case class HashedRelationInfo(
     relationTerm: String,
     keyIsUnique: Boolean,
     isEmpty: Boolean)
-
+private[joins] case class HashJoinParams(

Review Comment:
   +1
   
   Usually we have blank line between class/trait definition.



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


[GitHub] [spark] viirya commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1260694736


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(
+      joinType: JoinType,
+      output: Seq[Attribute],
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): (InternalRow) => InternalRow = {
+    joinType match {
+      case LeftExistence(_) =>
+        UnsafeProjection.create(output, output)
+      case _ =>
+        // Always put the stream side on left to simplify implementation
+        // both of left and right side could be null
+        UnsafeProjection.create(
+          output, (streamedPlanOutput ++ buildPlanOutput).map(_.withNullability(true)))
+    }
+  }
+  def join(hashJoinParams: HashJoinParams): Iterator[InternalRow] = {
+
+    val streamedIter: Iterator[InternalRow] = hashJoinParams.streamedIter
+    val hashed: HashedRelation = hashJoinParams.hashedRelation
+    val streamedKeys: Seq[Expression] = hashJoinParams.streamedKeys
+    val streamedOutput: Seq[Attribute] = hashJoinParams.streamedOutput
+    val condition: Option[Expression] = hashJoinParams.condition
+    val joinType: JoinType = hashJoinParams.joinType
+    val buildSide: BuildSide = hashJoinParams.buildSide
+    val buildPlanOutput: Seq[Attribute] = hashJoinParams.buildPlanOutput
+    val streamedPlanOutput: Seq[Attribute] = hashJoinParams.streamedPlanOutput
+    val output: Seq[Attribute] = hashJoinParams.output
+    val numOutputRows: SQLMetric = hashJoinParams.numOutputRows
+
+    val joinedIter = joinType match {
+      case _: InnerLike =>
+        innerJoin(
+          streamedIter,
+          hashed,
+          streamedKeys,
+          streamedOutput,
+          condition,
+          joinType,
+          buildSide,
+          buildPlanOutput,
+          streamedPlanOutput)

Review Comment:
   Hmm, seems previously these methods only take two parameters (stream iterator and hash relation. Maybe we can initiates the two parameters before calling these methods, so they can keep two parameters as before?



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


[GitHub] [spark] vinodkc commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1256802160


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/ShuffledHashJoinEvaluatorFactory.scala:
##########
@@ -0,0 +1,312 @@
+/*
+ * 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.joins
+
+import org.apache.spark.{PartitionEvaluator, PartitionEvaluatorFactory, TaskContext}
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression, GenericInternalRow, JoinedRow, Predicate, UnsafeProjection}
+import org.apache.spark.sql.catalyst.optimizer.{BuildLeft, BuildRight, BuildSide}
+import org.apache.spark.sql.catalyst.plans.{FullOuter, JoinType, LeftOuter, RightOuter}
+import org.apache.spark.sql.execution.RowIterator
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.util.collection.{BitSet, OpenHashSet}
+
+class ShuffledHashJoinEvaluatorFactory(
+    output: Seq[Attribute],
+    condition: Option[Expression],
+    buildPlanOutput: Seq[Attribute],
+    streamedPlanOutput: Seq[Attribute],
+    joinType: JoinType,
+    buildSide: BuildSide,
+    join: (Iterator[InternalRow], HashedRelation, SQLMetric) => Iterator[InternalRow],

Review Comment:
   Done. Avoided serializing lambda



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


[GitHub] [spark] vinodkc commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "vinodkc (via GitHub)" <gi...@apache.org>.
vinodkc commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1262768573


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala:
##########
@@ -766,4 +598,331 @@ object HashJoin extends CastSupport with SQLConfHelper {
         ansiEnabled = false)
     }
   }
+
+  private def streamedBoundKeys(streamedKeys: Seq[Expression], streamedOutput: Seq[Attribute]) =
+    bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+  private def streamSideKeyGenerator(
+      streamedKeys: Seq[Expression],
+      streamedOutput: Seq[Attribute]): UnsafeProjection =
+    UnsafeProjection.create(streamedBoundKeys(streamedKeys, streamedOutput))
+
+  def boundCondition(
+      condition: Option[Expression],
+      joinType: JoinType,
+      buildSide: BuildSide,
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): InternalRow => Boolean = if (condition.isDefined) {
+    if (joinType == FullOuter && buildSide == BuildLeft) {
+      // Put join left side before right side. This is to be consistent with
+      // `ShuffledHashJoinExec.fullOuterJoin`.
+      Predicate.create(condition.get, buildPlanOutput ++ streamedPlanOutput).eval _
+    } else {
+      Predicate.create(condition.get, streamedPlanOutput ++ buildPlanOutput).eval _
+    }
+  } else { (r: InternalRow) =>
+    true
+  }
+
+  private def createResultProjection(
+      joinType: JoinType,
+      output: Seq[Attribute],
+      buildPlanOutput: Seq[Attribute],
+      streamedPlanOutput: Seq[Attribute]): (InternalRow) => InternalRow = {
+    joinType match {
+      case LeftExistence(_) =>
+        UnsafeProjection.create(output, output)
+      case _ =>
+        // Always put the stream side on left to simplify implementation
+        // both of left and right side could be null
+        UnsafeProjection.create(
+          output, (streamedPlanOutput ++ buildPlanOutput).map(_.withNullability(true)))
+    }
+  }
+  def join(hashJoinParams: HashJoinParams): Iterator[InternalRow] = {
+
+    val streamedIter: Iterator[InternalRow] = hashJoinParams.streamedIter
+    val hashed: HashedRelation = hashJoinParams.hashedRelation
+    val streamedKeys: Seq[Expression] = hashJoinParams.streamedKeys
+    val streamedOutput: Seq[Attribute] = hashJoinParams.streamedOutput
+    val condition: Option[Expression] = hashJoinParams.condition
+    val joinType: JoinType = hashJoinParams.joinType
+    val buildSide: BuildSide = hashJoinParams.buildSide
+    val buildPlanOutput: Seq[Attribute] = hashJoinParams.buildPlanOutput
+    val streamedPlanOutput: Seq[Attribute] = hashJoinParams.streamedPlanOutput
+    val output: Seq[Attribute] = hashJoinParams.output
+    val numOutputRows: SQLMetric = hashJoinParams.numOutputRows
+
+    val joinedIter = joinType match {
+      case _: InnerLike =>
+        innerJoin(
+          streamedIter,
+          hashed,
+          streamedKeys,
+          streamedOutput,
+          condition,
+          joinType,
+          buildSide,
+          buildPlanOutput,
+          streamedPlanOutput)

Review Comment:
   In order to avoid passing lambda to join() method, I refactored join methods and moved them to  `object HashJoin....`, so those new object methods  (e.g `innerJoin` )need to be called with additional parameters. Hence I'm not finding a way to keep the original signature of them.



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


[GitHub] [spark] viirya commented on a diff in pull request #41875: [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41875:
URL: https://github.com/apache/spark/pull/41875#discussion_r1264611443


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/ShuffledHashJoinEvaluatorFactory.scala:
##########
@@ -0,0 +1,355 @@
+/*
+ * 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.joins
+
+import scala.concurrent.duration.NANOSECONDS
+
+import org.apache.spark.{PartitionEvaluator, PartitionEvaluatorFactory, TaskContext}
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeSet, BindReferences, Expression, GenericInternalRow, JoinedRow, UnsafeProjection}
+import org.apache.spark.sql.catalyst.optimizer.{BuildLeft, BuildRight, BuildSide}
+import org.apache.spark.sql.catalyst.plans.{FullOuter, JoinType, LeftExistence, LeftOuter, RightOuter}
+import org.apache.spark.sql.execution.RowIterator
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.util.collection.{BitSet, OpenHashSet}
+
+class ShuffledHashJoinEvaluatorFactory(
+    output: Seq[Attribute],
+    condition: Option[Expression],
+    buildKeys: Seq[Expression],
+    streamedKeys: Seq[Expression],
+    buildPlanOutput: Seq[Attribute],
+    streamedPlanOutput: Seq[Attribute],
+    joinType: JoinType,
+    buildSide: BuildSide,
+    streamedOutput: Seq[Attribute],
+    buildOutput: Seq[Attribute],
+    numOutputRows: SQLMetric,
+    buildDataSize: SQLMetric,
+    buildTime: SQLMetric)
+    extends PartitionEvaluatorFactory[InternalRow, InternalRow] {
+  override def createEvaluator(): PartitionEvaluator[InternalRow, InternalRow] =
+    new ShuffledHashJoinEvaluator
+
+  private class ShuffledHashJoinEvaluator extends PartitionEvaluator[InternalRow, InternalRow] {
+    override def eval(
+        partitionIndex: Int,
+        inputs: Iterator[InternalRow]*): Iterator[InternalRow] = {
+      assert(inputs.length == 2)
+      val streamIter = inputs(0)
+      val buildIter = inputs(1)
+      val hashed = buildHashedRelation(buildIter)
+      joinType match {
+        case FullOuter =>
+          buildSideOrFullOuterJoin(streamIter, hashed, numOutputRows, isFullOuterJoin = true)
+        case LeftOuter if buildSide.equals(BuildLeft) =>
+          buildSideOrFullOuterJoin(streamIter, hashed, numOutputRows, isFullOuterJoin = false)
+        case RightOuter if buildSide.equals(BuildRight) =>
+          buildSideOrFullOuterJoin(streamIter, hashed, numOutputRows, isFullOuterJoin = false)
+        case _ =>
+          HashJoin.join(
+            HashJoinParams(
+              streamIter,
+              hashed,
+              condition,
+              streamedKeys,
+              streamedOutput,
+              buildPlanOutput,
+              streamedPlanOutput,
+              output,
+              joinType,
+              buildSide,
+              numOutputRows))
+      }
+    }
+
+    private lazy val boundCondition: InternalRow => Boolean =
+      HashJoin.boundCondition(condition, joinType, buildSide, buildPlanOutput, streamedPlanOutput)
+
+    lazy val ignoreDuplicatedKey = joinType match {
+      case LeftExistence(_) =>
+        // For building hash relation, ignore duplicated rows with same join keys if:
+        // 1. Join condition is empty, or
+        // 2. Join condition only references streamed attributes and build join keys.
+        val streamedOutputAndBuildKeys = AttributeSet(streamedOutput ++ buildKeys)
+        condition.forall(_.references.subsetOf(streamedOutputAndBuildKeys))
+      case _ => false
+    }
+
+    private lazy val streamedBoundKeys =
+      BindReferences.bindReferences(HashJoin.rewriteKeyExpr(streamedKeys), streamedOutput)
+
+    private lazy val buildBoundKeys =
+      BindReferences.bindReferences(HashJoin.rewriteKeyExpr(buildKeys), buildOutput)
+
+    private def streamSideKeyGenerator(): UnsafeProjection =
+      UnsafeProjection.create(streamedBoundKeys)
+    private def buildHashedRelation(iter: Iterator[InternalRow]): HashedRelation = {

Review Comment:
   ```suggestion
       private def streamSideKeyGenerator(): UnsafeProjection =
         UnsafeProjection.create(streamedBoundKeys)
         
       private def buildHashedRelation(iter: Iterator[InternalRow]): HashedRelation = {
   ```



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


Re: [PR] [SPARK-44317][SQL] Use PartitionEvaluator API in ShuffledHashJoinExec [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41875:
URL: https://github.com/apache/spark/pull/41875#issuecomment-1793262501

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


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