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-49773][SQL] Uncaught Java exception from make_timestamp() with bad timezone #48260

Closed
wants to merge 15 commits into from

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Sep 26, 2024

What changes were proposed in this pull request?

This PR proposes to fix the uncaught Java exception from make_timestamp() with bad timezone

Why are the changes needed?

To improve the error message

Does this PR introduce any user-facing change?

No API changes, but the user-facing error message is changed:

Before

spark-sql (default)> select make_timestamp(1, 2, 28, 23, 1, 1, -100);
Invalid ID for ZoneOffset, invalid format: -100

After

spark-sql (default)> select make_timestamp(1, 2, 28, 23, 1, 1, -100);
[INVALID_TIMEZONE] The timezone: -100 is invalid.  The timezone must be either a region-based zone ID or a zone offset. Region IDs must have the form ‘area/city’, such as ‘America/Los_Angeles’. Zone offsets must be in the format ‘(+|-)HH’, ‘(+|-)HH:mm’ or ‘(+|-)HH:mm:ss’, e.g ‘-08’, ‘+01:00’ or ‘-13:33:33’., and must be in the range from -18:00 to +18:00. 'Z' and 'UTC' are accepted as synonyms for '+00:00'. SQLSTATE: 22009

How was this patch tested?

CI

Was this patch authored or co-authored using generative AI tooling?

No

@itholic
Copy link
Contributor Author

itholic commented Sep 26, 2024

cc @srielau @cloud-fan

@github-actions github-actions bot added the SQL label Sep 26, 2024
Copy link
Contributor

@srielau srielau left a comment

Choose a reason for hiding this comment

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

Please provide teh bad value and imporve teh error message. I have provided a proposal.

Copy link
Contributor

@srielau srielau left a comment

Choose a reason for hiding this comment

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

Fixed the ticks, sorry

Co-authored-by: Serge Rielau <srielau@users.noreply.github.com>
@itholic
Copy link
Contributor Author

itholic commented Oct 2, 2024

Thanks for the fix!

Copy link
Member

@MaxGekk MaxGekk left a comment

Choose a reason for hiding this comment

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

Could you add a test for the new error condition INVALID_TIMEZONE, please.

@itholic
Copy link
Contributor Author

itholic commented Oct 5, 2024

Added test. Thanks!

Copy link
Member

@MaxGekk MaxGekk left a comment

Choose a reason for hiding this comment

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

Waiting for CI.

@MaxGekk MaxGekk changed the title [SPARK-49773][SQL] uncaught Java exception from make_timestamp() with bad timezone [SPARK-49773][SQL] Uncaught Java exception from make_timestamp() with bad timezone Oct 5, 2024
@itholic itholic closed this in 9ce0564 Oct 7, 2024
@itholic
Copy link
Contributor Author

itholic commented Oct 7, 2024

Merged to master.
Thanks @srielau and @MaxGekk for the review!

himadripal pushed a commit to himadripal/spark that referenced this pull request Oct 19, 2024
…th bad timezone

### What changes were proposed in this pull request?

This PR proposes to fix the uncaught Java exception from `make_timestamp()` with bad timezone

### Why are the changes needed?

To improve the error message

### Does this PR introduce _any_ user-facing change?

No API changes, but the user-facing error message is changed:

**Before**
```
spark-sql (default)> select make_timestamp(1, 2, 28, 23, 1, 1, -100);
Invalid ID for ZoneOffset, invalid format: -100
```

**After**
```
spark-sql (default)> select make_timestamp(1, 2, 28, 23, 1, 1, -100);
[INVALID_TIMEZONE] The timezone: -100 is invalid.  The timezone must be either a region-based zone ID or a zone offset. Region IDs must have the form ‘area/city’, such as ‘America/Los_Angeles’. Zone offsets must be in the format ‘(+|-)HH’, ‘(+|-)HH:mm’ or ‘(+|-)HH:mm:ss’, e.g ‘-08’, ‘+01:00’ or ‘-13:33:33’., and must be in the range from -18:00 to +18:00. 'Z' and 'UTC' are accepted as synonyms for '+00:00'. SQLSTATE: 22009
```

### How was this patch tested?

CI

### Was this patch authored or co-authored using generative AI tooling?

No

Closes apache#48260 from itholic/SPARK-49773.

Lead-authored-by: Haejoon Lee <haejoon.lee@databricks.com>
Co-authored-by: Haejoon Lee <haejoon@apache.org>
Signed-off-by: Haejoon Lee <haejoon.lee@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants