leanken commented on a change in pull request #29104:
URL: https://github.com/apache/spark/pull/29104#discussion_r456728044



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/NotInSubqueryHashJoinTestSuite.scala
##########
@@ -0,0 +1,64 @@
+/*
+ * 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
+
+import java.io.File
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.internal.SQLConf
+
+/**
+ * End-to-end test cases for subquery SQL queries coverage with
+ * NOT_IN_SUBQUERY_HASH_JOIN_ENABLED = true.
+ *
+ * Each case is loaded from a file in
+ * "spark/sql/core/src/test/resources/sql-tests/inputs/subquery".
+ * Each case has a golden result file in
+ * "spark/sql/core/src/test/resources/sql-tests/results/subquery".
+ *
+ * To run the entire test suite:
+ * {{{
+ *   build/sbt "sql/test-only *NotInSubqueryHashJoinTestSuite"
+ * }}}
+ *
+ */
+class NotInSubqueryHashJoinTestSuite extends SQLQueryTestSuite {
+
+  protected override def sparkConf: SparkConf = super.sparkConf
+    // Fewer shuffle partitions to speed up testing.
+    // enable NOT_IN_SUBQUERY_HASH_JOIN_ENABLED for subquery case coverage.
+    .set(SQLConf.SHUFFLE_PARTITIONS, 4)
+    .set(SQLConf.NOT_IN_SUBQUERY_HASH_JOIN_ENABLED, true)
+
+  override lazy val listTestCases: Seq[TestCase] = {
+    listFilesRecursively(new File(inputFilePath)).flatMap { file =>
+      val resultFile = file.getAbsolutePath.replace(inputFilePath, 
goldenFilePath) + ".out"
+      val absPath = file.getAbsolutePath
+      val testCaseName =
+        s"notInSubqueryHashJoin@" +
+          s"${absPath.stripPrefix(inputFilePath).stripPrefix(File.separator)}"
+
+      if (file.getAbsolutePath.startsWith(
+        s"$inputFilePath${File.separator}subquery")) {
+        RegularTestCase(testCaseName, absPath, resultFile) :: Nil

Review comment:
       I will add some cases in org.apache.spark.sql.JoinSuite
   should be something like follow.
   ```
   test("join operator selection") {
       spark.sharedState.cacheManager.clearCache()
   
       withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "0",
         SQLConf.CROSS_JOINS_ENABLED.key -> "true") {
         Seq(
           ("SELECT * FROM testData LEFT SEMI JOIN testData2 ON key = a",
             classOf[SortMergeJoinExec]),
           ("SELECT * FROM testData LEFT SEMI JOIN testData2", 
classOf[BroadcastNestedLoopJoinExec]),
           ("SELECT * FROM testData JOIN testData2", 
classOf[CartesianProductExec]),
           ("SELECT * FROM testData JOIN testData2 WHERE key = 2", 
classOf[CartesianProductExec]),
           ("SELECT * FROM testData LEFT JOIN testData2", 
classOf[BroadcastNestedLoopJoinExec]),
           ("SELECT * FROM testData RIGHT JOIN testData2", 
classOf[BroadcastNestedLoopJoinExec]),
           ("SELECT * FROM testData FULL OUTER JOIN testData2", 
classOf[BroadcastNestedLoopJoinExec]),
           ("SELECT * FROM testData LEFT JOIN testData2 WHERE key = 2",
             classOf[BroadcastNestedLoopJoinExec]),
           ("SELECT * FROM testData RIGHT JOIN testData2 WHERE key = 2",
             classOf[CartesianProductExec]),
   ```




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to