diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala index 71e881a0c6cc7..c0fe2144cedc2 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala @@ -41,6 +41,7 @@ import org.apache.spark.tags.ExtendedSQLTest * * Each case is loaded from a file in "spark/sql/core/src/test/resources/sql-tests/inputs". * Each case has a golden result file in "spark/sql/core/src/test/resources/sql-tests/results". + * Please note that the test name is constructed via actual file name with excluding '.sql' suffix. * * To run the entire test suite: * {{{ @@ -49,7 +50,7 @@ import org.apache.spark.tags.ExtendedSQLTest * * To run a single test file upon change: * {{{ - * build/sbt "~sql/test-only *SQLQueryTestSuite -- -z inline-table.sql" + * build/sbt "~sql/test-only *SQLQueryTestSuite -- -z inline-table" * }}} * * To re-generate golden files for entire suite, run: @@ -59,7 +60,7 @@ import org.apache.spark.tags.ExtendedSQLTest * * To re-generate golden file for a single test, run: * {{{ - * SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/test-only *SQLQueryTestSuite -- -z describe.sql" + * SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/test-only *SQLQueryTestSuite -- -z describe" * }}} * * The format for input files is simple: @@ -141,7 +142,7 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession { /** List of test cases to ignore, in lower cases. */ protected def blackList: Set[String] = Set( - "blacklist.sql" // Do NOT remove this one. It is here to test the blacklist functionality. + "blacklist" // Do NOT remove this one. It is here to test the blacklist functionality. ) // Create all the test cases. @@ -444,11 +445,19 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession { .replaceAll("\\*\\(\\d+\\) ", "*") // remove the WholeStageCodegen codegenStageIds } + protected def extractTestCaseName(absolutePath: String): String = { + // Removing last '.sql' is an workaround of sbt bug which removes test name + // prior to the last dot in JUnitXmlReportPlugin. + // Please refer https://github.com/sbt/sbt/issues/2949 + absolutePath.stripPrefix(inputFilePath).stripPrefix(File.separator) + .stripSuffix(validFileExtensions) + } + protected def listTestCases(): Seq[TestCase] = { listFilesRecursively(new File(inputFilePath)).flatMap { file => val resultFile = file.getAbsolutePath.replace(inputFilePath, goldenFilePath) + ".out" val absPath = file.getAbsolutePath - val testCaseName = absPath.stripPrefix(inputFilePath).stripPrefix(File.separator) + val testCaseName = extractTestCaseName(absPath) if (file.getAbsolutePath.startsWith( s"$inputFilePath${File.separator}udf${File.separator}pgSQL")) { diff --git a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerQueryTestSuite.scala b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerQueryTestSuite.scala index fbcf97c2b6686..fa7adfdf689ba 100644 --- a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerQueryTestSuite.scala +++ b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerQueryTestSuite.scala @@ -84,23 +84,23 @@ class ThriftServerQueryTestSuite extends SQLQueryTestSuite { /** List of test cases to ignore, in lower cases. */ override def blackList: Set[String] = Set( - "blacklist.sql", // Do NOT remove this one. It is here to test the blacklist functionality. + "blacklist", // Do NOT remove this one. It is here to test the blacklist functionality. // Missing UDF - "pgSQL/boolean.sql", - "pgSQL/case.sql", + "pgSQL/boolean", + "pgSQL/case", // SPARK-28624 - "date.sql", + "date", // SPARK-28620 - "pgSQL/float4.sql", + "pgSQL/float4", // SPARK-28636 - "decimalArithmeticOperations.sql", - "literals.sql", - "subquery/scalar-subquery/scalar-subquery-predicate.sql", - "subquery/in-subquery/in-limit.sql", - "subquery/in-subquery/in-group-by.sql", - "subquery/in-subquery/simple-in.sql", - "subquery/in-subquery/in-order-by.sql", - "subquery/in-subquery/in-set-operations.sql" + "decimalArithmeticOperations", + "literals", + "subquery/scalar-subquery/scalar-subquery-predicate", + "subquery/in-subquery/in-limit", + "subquery/in-subquery/in-group-by", + "subquery/in-subquery/simple-in", + "subquery/in-subquery/in-order-by", + "subquery/in-subquery/in-set-operations" ) override def runQueries( @@ -234,7 +234,7 @@ class ThriftServerQueryTestSuite extends SQLQueryTestSuite { listFilesRecursively(new File(inputFilePath)).flatMap { file => val resultFile = file.getAbsolutePath.replace(inputFilePath, goldenFilePath) + ".out" val absPath = file.getAbsolutePath - val testCaseName = absPath.stripPrefix(inputFilePath).stripPrefix(File.separator) + val testCaseName = extractTestCaseName(absPath) if (file.getAbsolutePath.startsWith(s"$inputFilePath${File.separator}udf")) { Seq.empty