Skip to content

[SPARK-52875][SQL][TESTS][FOLLOWUP] Override the sparkConf for DataSourceV2StrategySuite to ensure that ANSI_ENABLED is set to true. #51652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Jul 24, 2025

What changes were proposed in this pull request?

This pr ensures that the test case Partial constant folding of math functions in DataSourceV2StrategySuite is only run when ansiEnabled is set to true.

Why are the changes needed?

Restore Non-Ansi daily test:

image

Does this PR introduce any user-facing change?

No

How was this patch tested?

SPARK_ANSI_SQL_MODE=false build/sbt "sql/testOnly org.apache.spark.sql.execution.datasources.v2.DataSourceV2StrategySuite"
[info] Run completed in 1 second, 939 milliseconds.
[info] Total number of tests run: 11
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 11, failed 0, canceled 1, ignored 0, pending 0
[info] All tests passed.

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions bot added the SQL label Jul 24, 2025
@@ -772,6 +773,7 @@ class DataSourceV2StrategySuite extends PlanTest with SharedSparkSession {
}

test("Partial constant folding of math functions") {
assume(SQLConf.get.ansiEnabled)
checkV2Conversion(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that checkV2Conversion cannot use the withSQLConf method to enforce ansiEnabled to be true, so an assume statement has been added here instead. Do you think this approach is acceptable? @cloud-fan

private def checkV2Conversion(
catalystExpr: Expression,
v2Expr: V2Expression,
isPredicate: Boolean = false): Unit = {
val v2ExprActual = new V2ExpressionBuilder(catalystExpr, isPredicate).build().getOrElse {
fail(s"can't convert to V2 expression: $catalystExpr")
}
assert(v2ExprActual == v2Expr, "V2 expressions must match")
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we override def sparkConf to enable ansi for the entire suite? DS v2 needs to turn on ANSI to translate expressions.

@LuciferYang LuciferYang changed the title [SPARK-52875][SQL][TESTS][FOLLOWUP] Test Partial constant folding of math functions only when ansiEnabled is true [SPARK-52875][SQL][TESTS][FOLLOWUP] Override the sparkConf for DataSourceV2StrategySuite to ensure that ANSI_ENABLED is set to true. Jul 25, 2025
@LuciferYang
Copy link
Contributor Author

Close this PR because it has already been fixed in #51660.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants