@@ -77,25 +77,31 @@ class CometSqlFileTestSuite extends CometTestBase with AdaptiveSparkPlanHelper {
7777 " spark.sql.optimizer.excludedRules" ->
7878 " org.apache.spark.sql.catalyst.optimizer.ConstantFolding" )
7979
80- private def runTestFile (file : SqlTestFile ): Unit = {
80+ private def runTestFile (relativePath : String , file : SqlTestFile ): Unit = {
8181 val allConfigs = file.configs ++ constantFoldingExcluded
8282 withSQLConf(allConfigs : _* ) {
8383 withTable(file.tables: _* ) {
8484 file.records.foreach {
85- case SqlStatement (sql) =>
86- spark.sql(sql)
87- case SqlQuery (sql, mode) =>
88- mode match {
89- case CheckCoverageAndAnswer =>
90- checkSparkAnswerAndOperator(sql)
91- case SparkAnswerOnly =>
92- checkSparkAnswer(sql)
93- case WithTolerance (tol) =>
94- checkSparkAnswerWithTolerance(sql, tol)
95- case ExpectFallback (reason) =>
96- checkSparkAnswerAndFallbackReason(sql, reason)
97- case Ignore (reason) =>
98- logInfo(s " IGNORED query ( ${reason}): $sql" )
85+ case SqlStatement (sql, line) =>
86+ val location = if (line > 0 ) s " $relativePath: $line" else relativePath
87+ withClue(s " In SQL file $location, executing statement: \n $sql\n " ) {
88+ spark.sql(sql)
89+ }
90+ case SqlQuery (sql, mode, line) =>
91+ val location = if (line > 0 ) s " $relativePath: $line" else relativePath
92+ withClue(s " In SQL file $location, executing query: \n $sql\n " ) {
93+ mode match {
94+ case CheckCoverageAndAnswer =>
95+ checkSparkAnswerAndOperator(sql)
96+ case SparkAnswerOnly =>
97+ checkSparkAnswer(sql)
98+ case WithTolerance (tol) =>
99+ checkSparkAnswerWithTolerance(sql, tol)
100+ case ExpectFallback (reason) =>
101+ checkSparkAnswerAndFallbackReason(sql, reason)
102+ case Ignore (reason) =>
103+ logInfo(s " IGNORED query ( ${reason}): $sql" )
104+ }
99105 }
100106 }
101107 }
@@ -118,7 +124,7 @@ class CometSqlFileTestSuite extends CometTestBase with AdaptiveSparkPlanHelper {
118124 logInfo(s " SKIPPED (requires Spark ${parsed.minSparkVersion.get}): $relativePath" )
119125 } else {
120126 val effectiveConfigs = parsed.configs ++ combinations.headOption.getOrElse(Seq .empty)
121- runTestFile(parsed.copy(configs = effectiveConfigs))
127+ runTestFile(relativePath, parsed.copy(configs = effectiveConfigs))
122128 }
123129 }
124130 } else {
@@ -129,7 +135,7 @@ class CometSqlFileTestSuite extends CometTestBase with AdaptiveSparkPlanHelper {
129135 if (skip) {
130136 logInfo(s " SKIPPED (requires Spark ${parsed.minSparkVersion.get}): $relativePath" )
131137 } else {
132- runTestFile(parsed.copy(configs = parsed.configs ++ matrixConfigs))
138+ runTestFile(relativePath, parsed.copy(configs = parsed.configs ++ matrixConfigs))
133139 }
134140 }
135141 }
0 commit comments