[SPARK-49642][SQL] Remove the ANSI config suggestion in DATETIME_FIELD_OUT_OF_BOUNDS#54695
Conversation
96c0ccb to
c298038
Compare
|
Rebased on master. Local run: SQLQueryTestSuite for date/timestamp/datetime-legacy/timestamp-ansi (18 tests) and QueryExecutionAnsiErrorsSuite::SPARK-49642 (1 test)—all passed. |
c298038 to
8b93645
Compare
|
Branch is rebased on master and local SQL/ANSI tests passed. No further changes from my side, ready for review when someone has bandwidth. |
8b93645 to
351cbe0
Compare
|
Rebased on current master. Ran |
MaxGekk
left a comment
There was a problem hiding this comment.
1 blocking, 0 non-blocking, 0 nits. Correct approach, but the now-duplicate helper needs to be cleaned up before merging.
Design / architecture (1)
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:308:ansiDateTimeArgumentOutOfRangeWithoutSuggestionis now identical to this method — see inline
| messageParameters = Map( | ||
| "rangeMessage" -> e.getMessage, | ||
| "ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)), | ||
| errorClass = "DATETIME_FIELD_OUT_OF_BOUNDS.WITHOUT_SUGGESTION", |
There was a problem hiding this comment.
After this change, ansiDateTimeArgumentOutOfRangeWithoutSuggestion (lines 315–322) has an identical implementation to this method — same errorClass, same messageParameters, same context/summary/cause. The only remaining difference is the parameter type (Throwable vs Exception). The WithoutSuggestion suffix used to encode a real behavioral distinction; that distinction is gone now that both methods throw WITHOUT_SUGGESTION.
Suggested fix (self-contained in this PR):
- Widen this method's parameter to
Throwable(all callers passDateTimeException/RuntimeException, compatible on both the Java and Scala sides). - Delete
ansiDateTimeArgumentOutOfRangeWithoutSuggestion(lines 315–322). - Replace its 3 call sites in
DateTimeUtils.scala(lines 940, 955, 957) withansiDateTimeArgumentOutOfRange.
There was a problem hiding this comment.
Addressed this by widening ansiDateTimeArgumentOutOfRange to Throwable, deleting ansiDateTimeArgumentOutOfRangeWithoutSuggestion, and switching the three DateTimeUtils call sites over. Rebased on current master and reran ./build/sbt "sql/testOnly org.apache.spark.sql.errors.QueryExecutionAnsiErrorsSuite -- -z SPARK-49642" plus ./build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z time.sql" - both passed.
351cbe0 to
39325ab
Compare
MaxGekk
left a comment
There was a problem hiding this comment.
1 addressed, 0 remaining, 0 new.
0 blocking, 0 non-blocking, 0 nits.
The prior blocking finding (duplicate ansiDateTimeArgumentOutOfRange* helpers) is resolved — merged into a single ansiDateTimeArgumentOutOfRange(e: Throwable). Verified the behavior change reaches all callers: the make_date/make_timestamp sites in DateTimeExpressionUtils.java (which the PR doesn't touch) auto-rebind to the merged (Throwable) method and now emit WITHOUT_SUGGESTION — exactly what the updated golden files reflect. Golden-file coverage is complete, no imports are orphaned by dropping the toSQLConf(SQLConf...) call, QueryExecutionErrors is private[sql] (no public-API impact), and the new QueryExecutionAnsiErrorsSuite test covers the path end-to-end. LGTM.
PR description suggestions
- The description says "No new tests added", but the diff adds the
SPARK-49642: DATETIME_FIELD_OUT_OF_BOUNDS does not suggest ANSI configtest toQueryExecutionAnsiErrorsSuite. The test is a good addition — just update that line of the description.
39325ab to
b3fc7a1
Compare
|
Rebased this on current master and updated the PR description to mention the new |
MaxGekk
left a comment
There was a problem hiding this comment.
All prior items resolved; 0 new. (0 blocking, 0 non-blocking, 0 nits.)
- The earlier blocking finding (duplicate
ansiDateTimeArgumentOutOfRange*helpers) is resolved — a singleansiDateTimeArgumentOutOfRange(Throwable)→WITHOUT_SUGGESTION, with the 3DateTimeUtilssites rebinding to it. - My prior PR-description suggestion is addressed — the description now mentions the new
QueryExecutionAnsiErrorsSuiteregression test.
Re-verified the 9-file change on the rebased head: no source references to the removed DATETIME_FIELD_OUT_OF_BOUNDS.WITH_SUGGESTION remain, the error entry is well-formed (single WITHOUT_SUGGESTION subclass, sqlState 22023), the golden files are consistent, and the regression test asserts the message no longer contains spark.sql.ansi.enabled. Clean rebase (no scope pollution). LGTM.
|
+1, LGTM. Merging to master/4.x. |
…D_OUT_OF_BOUNDS ## Summary In Spark 4.0.0 ANSI mode is on by default. The JIRA asks to minimize suggestions that tell users to turn ANSI off. The error `DATETIME_FIELD_OUT_OF_BOUNDS` previously had a subclass `WITH_SUGGESTION` that appended "If necessary set spark.sql.ansi.enabled to false to bypass this error." This PR removes that suggestion; users can use `try_*` functions for safe behavior instead. The error now always uses `WITHOUT_SUGGESTION` (message is just the range description). ## Change - **error-conditions.json**: Removed the `WITH_SUGGESTION` subclass from `DATETIME_FIELD_OUT_OF_BOUNDS` (kept only `WITHOUT_SUGGESTION`). - **QueryExecutionErrors.scala**: `ansiDateTimeArgumentOutOfRange` now throws `DATETIME_FIELD_OUT_OF_BOUNDS.WITHOUT_SUGGESTION` with only `rangeMessage` (removed `ansiConfig` parameter). - **SQL test result files** (date.sql.out, timestamp.sql.out, timestampNTZ/timestamp-ansi.sql.out, postgreSQL/date.sql.out, datetime-legacy.sql.out): Updated expected error class from `WITH_SUGGESTION` to `WITHOUT_SUGGESTION` and removed `ansiConfig` from expected messageParameters where the error is `DATETIME_FIELD_OUT_OF_BOUNDS`. - **QueryExecutionAnsiErrorsSuite.scala**: Added a regression test for `DATETIME_FIELD_OUT_OF_BOUNDS` so the error does not suggest disabling ANSI mode. ## Tests Added `SPARK-49642: DATETIME_FIELD_OUT_OF_BOUNDS does not suggest ANSI config` in `QueryExecutionAnsiErrorsSuite`. Local validation: - `./build/sbt "sql/testOnly org.apache.spark.sql.errors.QueryExecutionAnsiErrorsSuite -- -z SPARK-49642"` passed. - `./build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z time.sql"` passed. Fixes SPARK-49642 **JIRA assignee for credit:** deepujain Closes #54695 from deepujain/SPARK-49642-remove-ansi-suggestion-datetime-out-of-bounds. Authored-by: Deepak Jain <deepujain@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com> (cherry picked from commit 890ce8d) Signed-off-by: Max Gekk <max.gekk@gmail.com>
|
@deepujain Congratulations with your first contribution to Apache Spark! |
Summary
In Spark 4.0.0 ANSI mode is on by default. The JIRA asks to minimize suggestions that tell users to turn ANSI off. The error
DATETIME_FIELD_OUT_OF_BOUNDSpreviously had a subclassWITH_SUGGESTIONthat appended "If necessary set spark.sql.ansi.enabled to false to bypass this error." This PR removes that suggestion; users can usetry_*functions for safe behavior instead. The error now always usesWITHOUT_SUGGESTION(message is just the range description).Change
WITH_SUGGESTIONsubclass fromDATETIME_FIELD_OUT_OF_BOUNDS(kept onlyWITHOUT_SUGGESTION).ansiDateTimeArgumentOutOfRangenow throwsDATETIME_FIELD_OUT_OF_BOUNDS.WITHOUT_SUGGESTIONwith onlyrangeMessage(removedansiConfigparameter).WITH_SUGGESTIONtoWITHOUT_SUGGESTIONand removedansiConfigfrom expected messageParameters where the error isDATETIME_FIELD_OUT_OF_BOUNDS.DATETIME_FIELD_OUT_OF_BOUNDSso the error does not suggest disabling ANSI mode.Tests
Added
SPARK-49642: DATETIME_FIELD_OUT_OF_BOUNDS does not suggest ANSI configinQueryExecutionAnsiErrorsSuite.Local validation:
./build/sbt "sql/testOnly org.apache.spark.sql.errors.QueryExecutionAnsiErrorsSuite -- -z SPARK-49642"passed../build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z time.sql"passed.Fixes SPARK-49642
JIRA assignee for credit: deepujain