You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "itholic (via GitHub)" <gi...@apache.org> on 2024/09/25 10:44:03 UTC

[PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

itholic opened a new pull request, #48242:
URL: https://github.com/apache/spark/pull/48242

   ### What changes were proposed in this pull request?
   
   This PR proposes to provide proper error conditions for `_LEGACY_ERROR_TEMP_2000` and improve the error message
   
   ### Why are the changes needed?
   
   To provide better user-facing error message
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API changes, but the user-facing error message will be improved:
   
   **Before**
   ```sql
   >>> spark.sql("SELECT make_date(2024, 13, 1);").show()
   Invalid value for MonthOfYear (valid values 1 - 12): 13. If necessary set "spark.sql.ansi.enabled" to false to bypass this error.
   ```
   
   **After**
   ```sql
   >>> spark.sql("SELECT make_date(2024, 13, 1);").show()
   [ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS] ANSI mode error: Invalid value for MonthOfYear (valid values 1 - 12): 13. If necessary set "spark.sql.ansi.enabled" to false to bypass this error. SQLSTATE: 22008
   ```
   
   ### How was this patch tested?
   
   The existing SQL tests should pass
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #48242: [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000`
URL: https://github.com/apache/spark/pull/48242


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #48242:
URL: https://github.com/apache/spark/pull/48242#issuecomment-2375514718

   Thanks @srielau for the review! Just adjusted the comments :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1775354297


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
+    "message" : [
+      "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."

Review Comment:
   This message makes no sense. The problem is not that ANIS mode is on. The problem is that the value is out of bounds.
   ```suggestion
         "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."
   ```
   We should produce a message as good as the existing one. We shoudl NOT just WRAP the existing message.
   State the unit: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
   State the range for the unit
   State the bad value



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #48242:
URL: https://github.com/apache/spark/pull/48242#issuecomment-2373729724

   cc @srielau @cloud-fan 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1777196074


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
+    "message" : [
+      "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."

Review Comment:
   A key premise of the error framework is to NOT leak 3. party libraries text and to have control over the language.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1775355385


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
+    "message" : [
+      "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."
+    ],
+    "sqlState" : "22008"

Review Comment:
   +1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1775346164


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {

Review Comment:
   ```suggestion
     "DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1777193690


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
+    "message" : [
+      "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."

Review Comment:
   We can check that for ourselves.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #48242:
URL: https://github.com/apache/spark/pull/48242#issuecomment-2597176454

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1777206615


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
+    "message" : [
+      "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."

Review Comment:
   ANother option is to catch the Java exception and search for the components.
   Just need teh few method names and the value. As long as we have tests for each thsi shoudl be safe.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000` [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #48242:
URL: https://github.com/apache/spark/pull/48242#discussion_r1776148120


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -70,6 +70,12 @@
     ],
     "sqlState" : "42000"
   },
+  "ANSI_DATE_TIME_FIELD_OUT_OF_BOUNDS" : {
+    "message" : [
+      "ANSI mode error: <message>. If necessary set <ansiConfig> to false to bypass this error."

Review Comment:
   We are currently catching `java.time.DateTimeException` as `e` and including `e.getMessage` in the error message, but `java.time.DateTimeException` does not provide the ability to obtain each parameter separately.
   
   I just reverted back to the existing error message so can we just use the existing error message for now??



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org