cloud-fan commented on a change in pull request #32355:
URL: https://github.com/apache/spark/pull/32355#discussion_r681629000
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/JoinHintSuite.scala
##########
@@ -597,4 +597,82 @@ class JoinHintSuite extends PlanTest with
SharedSparkSession with AdaptiveSparkP
assert(df9.collect().size == df10.collect().size)
}
}
+
+ test("SPARK-35221: Add join hint build side check") {
+ withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.PREFER_SORTMERGEJOIN.key -> "true") {
+ Seq("left_outer", "left_semi", "left_anti").foreach { joinType =>
+ val hintAppender = new LogAppender(s"join hint build side check for
$joinType")
+ withLogAppender(hintAppender, level = Some(Level.WARN)) {
+ assertShuffleMergeJoin(
+ df1.hint("BROADCAST").join(df2, $"a1" === $"b1", joinType))
+ assertBroadcastHashJoin(
+ df1.join(df2.hint("BROADCAST"), $"a1" === $"b1", joinType),
BuildRight)
+
+ assertShuffleMergeJoin(
+ df1.hint("SHUFFLE_HASH").join(df2, $"a1" === $"b1", joinType))
+ assertShuffleHashJoin(
+ df1.join(df2.hint("SHUFFLE_HASH"), $"a1" === $"b1", joinType),
BuildRight)
+ }
+
+ val logs = hintAppender.loggingEvents.map(_.getRenderedMessage)
+ .filter(_.contains("is not supported in the query:"))
+ assert(logs.nonEmpty)
+ logs.forall(_.contains(s"build left for
${joinType.split("_").mkString(" ")} join."))
+ }
+
+ Seq("right_outer").foreach { joinType =>
+ val hintAppender = new LogAppender(s"join hint build side check for
$joinType")
+ withLogAppender(hintAppender, level = Some(Level.WARN)) {
+ assertBroadcastHashJoin(
+ df1.hint("BROADCAST").join(df2, $"a1" === $"b1", joinType),
BuildLeft)
+ assertShuffleMergeJoin(
+ df1.join(df2.hint("BROADCAST"), $"a1" === $"b1", joinType))
+
+ assertShuffleHashJoin(
+ df1.hint("SHUFFLE_HASH").join(df2, $"a1" === $"b1", joinType),
BuildLeft)
+ assertShuffleMergeJoin(
+ df1.join(df2.hint("SHUFFLE_HASH"), $"a1" === $"b1", joinType))
+ }
+ val logs = hintAppender.loggingEvents.map(_.getRenderedMessage)
+ .filter(_.contains("is not supported in the query:"))
+ assert(logs.nonEmpty)
+ logs.forall(_.contains(s"build right for
${joinType.split("_").mkString(" ")} join."))
+ }
+
+ Seq("inner", "cross").foreach { joinType =>
+ val hintAppender = new LogAppender(s"join hint build side check for
$joinType")
+ withLogAppender(hintAppender, level = Some(Level.WARN)) {
+ assertBroadcastHashJoin(
+ df1.hint("BROADCAST").join(df2, $"a1" === $"b1", joinType),
BuildLeft)
+ assertBroadcastHashJoin(
+ df1.join(df2.hint("BROADCAST"), $"a1" === $"b1", joinType),
BuildRight)
+
+ assertShuffleHashJoin(
+ df1.hint("SHUFFLE_HASH").join(df2, $"a1" === $"b1", joinType),
BuildLeft)
+ assertShuffleHashJoin(
+ df1.join(df2.hint("SHUFFLE_HASH"), $"a1" === $"b1", joinType),
BuildRight)
+ }
+ val logs = hintAppender.loggingEvents.map(_.getRenderedMessage)
+ .filter(_.contains("is not supported in the query:"))
+ assert(logs.isEmpty)
+ }
+ }
+ }
+
+ test("SPARK-35221: Add join hint non equi-join check") {
+ val hintAppender = new LogAppender(s"join hint check for equi-join")
+ withLogAppender(hintAppender, level = Some(Level.WARN)) {
+ assertBroadcastNLJoin(
+ df1.hint("SHUFFLE_HASH").join(df2, $"a1" !== $"b1"), BuildRight)
+ }
+ withLogAppender(hintAppender, level = Some(Level.WARN)) {
+ assertBroadcastNLJoin(
+ df1.join(df2.hint("MERGE"), $"a1" !== $"b1"), BuildRight)
+ }
+ val logs = hintAppender.loggingEvents.map(_.getRenderedMessage)
+ .filter(_.contains("is not supported in the query:"))
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]