Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-49583][SQL] Define the error sub-condition
SECONDS_FRACTION
…
…for invalid seconds fraction pattern ### What changes were proposed in this pull request? In the PR, I propose new sub-condition `SECONDS_FRACTION` of the error condition `INVALID_DATETIME_PATTERN` in case when datetime pattern doesn't contain proper seconds fraction of variable length. ### Why are the changes needed? To fix the failure on internal assert. This change should improve user experience with Spark SQL. Before the changes, Spark fails while parsing the datetime patterns like `\nSSSS\r`: ``` java.lang.AssertionError: assertion failed at scala.Predef$.assert(Predef.scala:264) at org.apache.spark.ErrorClassesJsonReader.getMessageTemplate(ErrorClassesJSONReader.scala:91) at org.apache.spark.ErrorClassesJsonReader.getErrorMessage(ErrorClassesJSONReader.scala:46) ``` ### Does this PR introduce _any_ user-facing change? Should not. Only if user's code depends on the format of error message. After changes, users get the error: ``` org.apache.spark.SparkIllegalArgumentException: [INVALID_DATETIME_PATTERN.SECONDS_FRACTION] Unrecognized datetime pattern: . Cannot detect a seconds fraction pattern of variable length. Please make sure the pattern contains 'S', and does not contain illegal characters. SQLSTATE: 22007 ``` ### How was this patch tested? By running new test suites: ``` $ build/sbt "test:testOnly *org.apache.spark.sql.catalyst.util.DateTimeFormatterHelperSuite" ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes #48058 from MaxGekk/fix-INVALID_DATETIME_PATTERN. Authored-by: Max Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]>
- Loading branch information