Skip to content

Commit

Permalink
Expand to all cases in SQLQueryTestSuite & ThriftServerQueryTestSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
HeartSaVioR committed Sep 25, 2019
1 parent f714453 commit b3414a2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,30 +201,26 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession {
udf: TestUDF) extends TestCase with UDFTest with PgSQLTest

protected def createScalaTestCase(testCase: TestCase): Unit = {
// 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
val refinedTestCaseName = testCase.name.stripSuffix(validFileExtensions)
if (blackList.exists(t =>
refinedTestCaseName.toLowerCase(Locale.ROOT).contains(t.toLowerCase(Locale.ROOT)))) {
testCase.name.toLowerCase(Locale.ROOT).contains(t.toLowerCase(Locale.ROOT)))) {
// Create a test case to ignore this case.
ignore(refinedTestCaseName) { /* Do nothing */ }
ignore(testCase.name) { /* Do nothing */ }
} else testCase match {
case udfTestCase: UDFTest
if udfTestCase.udf.isInstanceOf[TestPythonUDF] && !shouldTestPythonUDFs =>
ignore(s"${refinedTestCaseName} is skipped because " +
ignore(s"${testCase.name} is skipped because " +
s"[$pythonExec] and/or pyspark were not available.") {
/* Do nothing */
}
case udfTestCase: UDFTest
if udfTestCase.udf.isInstanceOf[TestScalarPandasUDF] && !shouldTestScalarPandasUDFs =>
ignore(s"${refinedTestCaseName} is skipped because pyspark," +
ignore(s"${testCase.name} is skipped because pyspark," +
s"pandas and/or pyarrow were not available in [$pythonExec].") {
/* Do nothing */
}
case _ =>
// Create a test case to run this case.
test(refinedTestCaseName) {
test(testCase.name) {
runTest(testCase)
}
}
Expand Down Expand Up @@ -449,11 +445,20 @@ 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")) {
Seq(TestScalaUDF("udf"), TestPythonUDF("udf"), TestScalarPandasUDF("udf")).map { udf =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b3414a2

Please sign in to comment.