diff --git a/spark/src/test/scala/org/apache/comet/CometExpressionCoverageSuite.scala b/spark/src/test/scala/org/apache/comet/CometExpressionCoverageSuite.scala index 93e4acb13..45979a9c2 100644 --- a/spark/src/test/scala/org/apache/comet/CometExpressionCoverageSuite.scala +++ b/spark/src/test/scala/org/apache/comet/CometExpressionCoverageSuite.scala @@ -87,7 +87,11 @@ class CometExpressionCoverageSuite extends CometTestBase with AdaptiveSparkPlanH } } else { // Plain example like SELECT cos(0); - testSingleLineQuery("select 'dummy' x", s"${q.dropRight(1)}, x from tbl") + testSingleLineQuery( + "select 'dummy' x", + s"${q.dropRight(1)}, x from tbl", + excludedOptimizerRules = + Some("org.apache.spark.sql.catalyst.optimizer.ConstantFolding")) } CoverageResult(CoverageResultStatus.Passed.toString, Seq((q, "OK"))) } catch { diff --git a/spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala b/spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala index e7526550f..135b2f937 100644 --- a/spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala +++ b/spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala @@ -724,7 +724,8 @@ abstract class CometTestBase prepareQuery: String, testQuery: String, testName: String = "test", - tableName: String = "tbl"): Unit = { + tableName: String = "tbl", + excludedOptimizerRules: Option[String] = None): Unit = { withTempDir { dir => val path = new Path(dir.toURI.toString, testName).toUri.toString @@ -746,7 +747,8 @@ abstract class CometTestBase // ConstantFolding is a operator optimization rule in Catalyst that replaces expressions // that can be statically evaluated with their equivalent literal values. withSQLConf( - "spark.sql.optimizer.excludedRules" -> "org.apache.spark.sql.catalyst.optimizer.ConstantFolding") { + "spark.sql.optimizer.excludedRules" -> excludedOptimizerRules.getOrElse(""), + "spark.sql.adaptive.optimizer.excludedRules" -> excludedOptimizerRules.getOrElse("")) { checkSparkAnswerAndOperator(sql(testQuery)) } }