-
Notifications
You must be signed in to change notification settings - Fork 2k
[Enhancement] Convert sql function parse_datetime(...) to str_to_jodatime(...) with accepting 'T' and 'Z' in format for Trino transformer when sql_dialect='trino' #56565
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
Conversation
for function from_iso8601_timestamp -> timestamp Signed-off-by: Craig <[email protected]>
unit test for transforming Trino function: from_iso8601_timestamp -> timestamp Signed-off-by: Craig <[email protected]>
Signed-off-by: Craig <[email protected]>
Signed-off-by: Craig <[email protected]>
move function parse_datetime() transform to ComplexFunctionCallTransformer.java to process format string when needed Signed-off-by: Craig <[email protected]>
Move function parse_datetime() transform to ComplexFunctionCallTransformer.java Signed-off-by: Craig <[email protected]>
add a test case for str_to_jodatime() transform Signed-off-by: Craig <[email protected]>
Signed-off-by: Craig <[email protected]>
merge the if statement per SonarQube Cloud's check Signed-off-by: Craig <[email protected]>
remove case for parse_datetime: 'yyyy-MM-dd''T''HH:mm:ss''Z''' Signed-off-by: Craig <[email protected]>
Update per SonarQube check Signed-off-by: Craig <[email protected]>
@Youngwb please take a look |
// parse_datetime -> str_to_jodatime | ||
String formatString = ((StringLiteral) args[1]).getStringValue(); | ||
// "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" -> "yyyy-MM-ddTHH:mm:ss.SSS" | ||
formatString = formatString.replace("'T'", "T").replace("'Z'", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should handle any character within the quotes, rather than just handling the character 'T'.
eg. select parse_datetime('2025-01-01ABC00:00:00.000Z', 'yyyy-MM-dd''ABC''HH:mm:ss.SSS''Z''');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove all ' characters for the format parameter, plus removing all Z characters because str_to_jodatime doesn't support it (when it's OK in Trino).
current example with Z in the format parameter:
mysql> set sql_dialect=trino;
mysql> select parse_datetime('2023-08-02T14:37:02Z', 'yyyy-MM-dd''T''HH:mm:ssZ');
ERROR 1064 (HY000): Invalid format 'yyyy-MM-ddTHH:mm:ssZ' for '2023-08-02T14:37:02Z'
mysql> select parse_datetime('2023-08-02T14:37:02Z', 'yyyy-MM-dd''T''HH:mm:ss''Z''');
+----------------------------------------------------------------+
| str_to_jodatime('2023-08-02T14:37:02Z', 'yyyy-MM-ddTHH:mm:ss') |
+----------------------------------------------------------------+
| 2023-08-02 14:37:02 |
+----------------------------------------------------------------+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code updated and add one more test for function parse_datetime()
@click9000 Could you plz add some test to cover this case? |
Add one more test for function parse_datetime() to handle format case like 'yyyy-MM-dd''T''HH:mm:ss''Z''' Signed-off-by: Craig <[email protected]>
Remove all ' characters for the format parameter, plus removing all Z characters because str_to_jodatime doesn't support it (when it's OK in Trino) Signed-off-by: Craig <[email protected]>
|
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 4 / 4 (100.00%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
@Mergifyio backport branch-3.4 |
@Mergifyio backport branch-3.3 |
✅ Backports have been created |
✅ Backports have been created |
…time(...) with accepting 'T' and 'Z' in format for Trino transformer when sql_dialect='trino' (#56565) Signed-off-by: Craig <[email protected]> (cherry picked from commit b8e05fe)
…time(...) with accepting 'T' and 'Z' in format for Trino transformer when sql_dialect='trino' (#56565) Signed-off-by: Craig <[email protected]> (cherry picked from commit b8e05fe)
…time(...) with accepting 'T' and 'Z' in format for Trino transformer when sql_dialect='trino' (backport #56565) (#56789) Co-authored-by: Craig <[email protected]>
…time(...) with accepting 'T' and 'Z' in format for Trino transformer when sql_dialect='trino' (backport #56565) (#56790) Co-authored-by: Craig <[email protected]>
Why I'm doing:
For sql_dialect='trino' case, parse_datetime('2025-01-01T00:00:00.000Z', 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z''') should be transformed
What I'm doing:
Replace 'T' to T and remove 'Z' in the format string for function parse_datetime()
Example:
parse_datetime('2025-01-01T00:00:00.000Z', 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z''')
should be converted to
str_to_jodatime('2025-01-01T00:00:00.000Z',, 'yyyy-MM-ddTHH:mm:ss.SSS')
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: