Skip to content
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

[SPARK-39214][SQL][3.3] Improve errors related to CAST #36591

Closed

Conversation

MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented May 18, 2022

What changes were proposed in this pull request?

In the PR, I propose to rename the error classes:

  1. INVALID_SYNTAX_FOR_CAST -> CAST_INVALID_INPUT
  2. CAST_CAUSES_OVERFLOW -> CAST_OVERFLOW

and change error messages:

CAST_INVALID_INPUT:
The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. ...

CAST_OVERFLOW:
The value <value> of the type <sourceType> cannot be cast to <targetType> due to an overflow....

Also quote the SQL config "spark.sql.ansi.enabled" and a function name.

This is a backport of #36553.

Why are the changes needed?

To improve user experience with Spark SQL by making errors/error classes related to CAST more clear and unified.

Does this PR introduce any user-facing change?

Yes, the PR changes user-facing error messages.

How was this patch tested?

By running the modified test suites:

$ build/sbt "testOnly *CastSuite"
$ build/sbt "test:testOnly *DateFormatterSuite"
$ build/sbt "test:testOnly *TimestampFormatterSuite"
$ build/sbt "testOnly *DSV2SQLInsertTestSuite"
$ build/sbt "test:testOnly *InsertSuite"
$ build/sbt "testOnly *AnsiCastSuiteWithAnsiModeOff"

Authored-by: Max Gekk max.gekk@gmail.com
Signed-off-by: Max Gekk max.gekk@gmail.com
(cherry picked from commit 66648e9)
Signed-off-by: Max Gekk max.gekk@gmail.com

In the PR, I propose to rename the error classes:
1. INVALID_SYNTAX_FOR_CAST -> CAST_INVALID_INPUT
2. CAST_CAUSES_OVERFLOW -> CAST_OVERFLOW

and change error messages:

CAST_INVALID_INPUT:
`The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. ...`

CAST_OVERFLOW:
`The value <value> of the type <sourceType> cannot be cast to <targetType> due to an overflow....`

Also quote the SQL config `"spark.sql.ansi.enabled"` and a function name.

To improve user experience with Spark SQL by making errors/error classes related to CAST more clear and **unified**.

Yes, the PR changes user-facing error messages.

By running the modified test suites:
```
$ build/sbt "testOnly *CastSuite"
$ build/sbt "test:testOnly *DateFormatterSuite"
$ build/sbt "test:testOnly *TimestampFormatterSuite"
$ build/sbt "testOnly *DSV2SQLInsertTestSuite"
$ build/sbt "test:testOnly *InsertSuite"
$ build/sbt "testOnly *AnsiCastSuiteWithAnsiModeOff"
```

Closes apache#36553 from MaxGekk/error-class-improve-msg-2.

Authored-by: Max Gekk <max.gekk@gmail.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
(cherry picked from commit 66648e9)
Signed-off-by: Max Gekk <max.gekk@gmail.com>
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM (Pending CIs)

@MaxGekk
Copy link
Member Author

MaxGekk commented May 18, 2022

Merging to 3.3. Thank you, @gengliangwang and @dongjoon-hyun for review.

MaxGekk added a commit that referenced this pull request May 18, 2022
### What changes were proposed in this pull request?
In the PR, I propose to rename the error classes:
1. INVALID_SYNTAX_FOR_CAST -> CAST_INVALID_INPUT
2. CAST_CAUSES_OVERFLOW -> CAST_OVERFLOW

and change error messages:

CAST_INVALID_INPUT:
`The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. ...`

CAST_OVERFLOW:
`The value <value> of the type <sourceType> cannot be cast to <targetType> due to an overflow....`

Also quote the SQL config `"spark.sql.ansi.enabled"` and a function name.

This is a backport of #36553.

### Why are the changes needed?
To improve user experience with Spark SQL by making errors/error classes related to CAST more clear and **unified**.

### Does this PR introduce _any_ user-facing change?
Yes, the PR changes user-facing error messages.

### How was this patch tested?
By running the modified test suites:
```
$ build/sbt "testOnly *CastSuite"
$ build/sbt "test:testOnly *DateFormatterSuite"
$ build/sbt "test:testOnly *TimestampFormatterSuite"
$ build/sbt "testOnly *DSV2SQLInsertTestSuite"
$ build/sbt "test:testOnly *InsertSuite"
$ build/sbt "testOnly *AnsiCastSuiteWithAnsiModeOff"
```

Authored-by: Max Gekk <max.gekkgmail.com>
Signed-off-by: Max Gekk <max.gekkgmail.com>
(cherry picked from commit 66648e9)
Signed-off-by: Max Gekk <max.gekkgmail.com>

Closes #36591 from MaxGekk/error-class-improve-msg-2-3.3.

Authored-by: Max Gekk <max.gekk@gmail.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
@MaxGekk MaxGekk closed this May 18, 2022
@cfmcgrady cfmcgrady mentioned this pull request May 25, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants