[SPARK-51556][SQL] Add the try_to_time function#50335
Closed
MaxGekk wants to merge 3 commits intoapache:masterfrom
Closed
[SPARK-51556][SQL] Add the try_to_time function#50335MaxGekk wants to merge 3 commits intoapache:masterfrom
try_to_time function#50335MaxGekk wants to merge 3 commits intoapache:masterfrom
Conversation
try_to_time functiontry_to_time function
try_to_time functiontry_to_time function
Member
|
LGTM @MaxGekk ! |
dongjoon-hyun
approved these changes
Mar 21, 2025
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Thank you, @MaxGekk .
yaooqinn
approved these changes
Mar 21, 2025
Member
Author
|
Merging to master. Thank you, @the-sakthi @dongjoon-hyun @yaooqinn for review. |
Contributor
|
late LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In the PR, I propose new SQL function
try_to_timewhich is similar toto_timebut returns NULL instead of raising an error in the cases of malformed or non-matched to the given pattern input strings.Syntax
Arguments
str: A STRING expression representing a time.format: An optional format STRING expression.Returns
A TIME.
formatis supplied, it must conform with Datetime patterns.formatis not supplied, the function is a synonym forcast(expr AS TIME).formatis malformed or its application does not result in a well formed time, the function returns NULL.To return an error instead of NULL in case of a malformed
struseto_time.Examples
Why are the changes needed?
To improve user experience with Spark SQL. If an user needs to process wrongly formatted time values in a string format, and ignore errors, she/he can use
try_to_timeinstead ofto_time.Does this PR introduce any user-facing change?
Yes, it extends Spark SQL by new function.
How was this patch tested?
By running the affected test suites:
Was this patch authored or co-authored using generative AI tooling?
No.