HyukjinKwon commented on a change in pull request #32355: URL: https://github.com/apache/spark/pull/32355#discussion_r680435570
########## File path: sql/core/src/test/scala/org/apache/spark/sql/JoinHintSuite.scala ########## @@ -597,4 +597,68 @@ 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(_.startsWith("A join hint")) Review comment: nit but I think the test here can be flaky (e.g., the test will be broken if there's another log with "A join hint" added). What about just checking if there's a log that contains the message instead of checking the length of these logs? -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org