Skip to content

Commit 2eafed5

Browse files
committed
[SPARK-51547][SQL] Assign name to the error condition: _LEGACY_ERROR_TEMP_2130
### What changes were proposed in this pull request? In the PR, I propose to rename the legacy error condition `_LEGACY_ERROR_TEMP_2130` to `INVALID_DATETIME_PATTERN.WITH_SUGGESTION`. ### Why are the changes needed? Raising an error w/ a legacy error condition for the new feature: the TIME data type looks weird at least . ### Does this PR introduce _any_ user-facing change? No, only if user's code depends on the error condition. ### How was this patch tested? By running the modified test suites: ``` $ build/sbt "test:testOnly *SparkThrowableSuite" $ build/sbt "test:testOnly *TimeFormatterSuite" $ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite" ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#50307 from MaxGekk/assign-cond-2130. Authored-by: Max Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent fecfab4 commit 2eafed5

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

common/utils/src/main/resources/error/error-conditions.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,11 @@
24042404
"message" : [
24052405
"Cannot detect a seconds fraction pattern of variable length. Please make sure the pattern contains 'S', and does not contain illegal characters."
24062406
]
2407+
},
2408+
"WITH_SUGGESTION" : {
2409+
"message" : [
2410+
"You can form a valid datetime pattern with the guide from '<docroot>/sql-ref-datetime-pattern.html'."
2411+
]
24072412
}
24082413
},
24092414
"sqlState" : "22007"
@@ -7881,11 +7886,6 @@
78817886
"Conflict found: Field <field> <actual> differs from <field> <expected> derived from <candidate>."
78827887
]
78837888
},
7884-
"_LEGACY_ERROR_TEMP_2130" : {
7885-
"message" : [
7886-
"Fail to recognize '<pattern>' pattern in the DateTimeFormatter. You can form a valid datetime pattern with the guide from '<docroot>/sql-ref-datetime-pattern.html'."
7887-
]
7888-
},
78897889
"_LEGACY_ERROR_TEMP_2131" : {
78907890
"message" : [
78917891
"Exception when registering StreamingQueryListener."

sql/api/src/main/scala/org/apache/spark/sql/errors/ExecutionErrors.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private[sql] trait ExecutionErrors extends DataTypeErrorsBase {
7373

7474
def failToRecognizePatternError(pattern: String, e: Throwable): SparkRuntimeException = {
7575
new SparkRuntimeException(
76-
errorClass = "_LEGACY_ERROR_TEMP_2130",
76+
errorClass = "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
7777
messageParameters =
7878
Map("pattern" -> toSQLValue(pattern), "docroot" -> SparkBuildInfo.spark_doc_root),
7979
cause = e)

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/TimeFormatterSuite.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class TimeFormatterSuite extends SparkFunSuite with SQLHelper {
9393
exception = intercept[SparkRuntimeException] {
9494
TimeFormatter(invalidPattern)
9595
},
96-
condition = "_LEGACY_ERROR_TEMP_2130",
96+
condition = "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
9797
parameters = Map(
9898
"pattern" -> s"'$invalidPattern'",
9999
"docroot" -> SPARK_DOC_ROOT))

sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out

+6-3
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ struct<>
903903
-- !query output
904904
org.apache.spark.SparkRuntimeException
905905
{
906-
"errorClass" : "_LEGACY_ERROR_TEMP_2130",
906+
"errorClass" : "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
907+
"sqlState" : "22007",
907908
"messageParameters" : {
908909
"docroot" : "https://spark.apache.org/docs/latest",
909910
"pattern" : "'yyyy-MM-dd GGGGG'"
@@ -918,7 +919,8 @@ struct<>
918919
-- !query output
919920
org.apache.spark.SparkRuntimeException
920921
{
921-
"errorClass" : "_LEGACY_ERROR_TEMP_2130",
922+
"errorClass" : "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
923+
"sqlState" : "22007",
922924
"messageParameters" : {
923925
"docroot" : "https://spark.apache.org/docs/latest",
924926
"pattern" : "'dd MM yyyy EEEEEE'"
@@ -933,7 +935,8 @@ struct<>
933935
-- !query output
934936
org.apache.spark.SparkRuntimeException
935937
{
936-
"errorClass" : "_LEGACY_ERROR_TEMP_2130",
938+
"errorClass" : "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
939+
"sqlState" : "22007",
937940
"messageParameters" : {
938941
"docroot" : "https://spark.apache.org/docs/latest",
939942
"pattern" : "'dd MM yyyy EEEEE'"

sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp.sql.out

+6-3
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ struct<>
880880
-- !query output
881881
org.apache.spark.SparkRuntimeException
882882
{
883-
"errorClass" : "_LEGACY_ERROR_TEMP_2130",
883+
"errorClass" : "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
884+
"sqlState" : "22007",
884885
"messageParameters" : {
885886
"docroot" : "https://spark.apache.org/docs/latest",
886887
"pattern" : "'yyyy-MM-dd GGGGG'"
@@ -895,7 +896,8 @@ struct<>
895896
-- !query output
896897
org.apache.spark.SparkRuntimeException
897898
{
898-
"errorClass" : "_LEGACY_ERROR_TEMP_2130",
899+
"errorClass" : "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
900+
"sqlState" : "22007",
899901
"messageParameters" : {
900902
"docroot" : "https://spark.apache.org/docs/latest",
901903
"pattern" : "'dd MM yyyy EEEEEE'"
@@ -910,7 +912,8 @@ struct<>
910912
-- !query output
911913
org.apache.spark.SparkRuntimeException
912914
{
913-
"errorClass" : "_LEGACY_ERROR_TEMP_2130",
915+
"errorClass" : "INVALID_DATETIME_PATTERN.WITH_SUGGESTION",
916+
"sqlState" : "22007",
914917
"messageParameters" : {
915918
"docroot" : "https://spark.apache.org/docs/latest",
916919
"pattern" : "'dd MM yyyy EEEEE'"

0 commit comments

Comments
 (0)