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

Deprecate Joda library for Presto Teradata functions #15537

Merged
merged 1 commit into from Mar 8, 2021

Conversation

rk13
Copy link
Contributor

@rk13 rk13 commented Dec 16, 2020

Test plan - (Please fill in how you tested your changes)

# make sure all test scenarios are covered
mvn clean test

Please make sure your submission complies with our Development, Formatting, and Commit Message guidelines. Don't forget to follow our attribution guidelines for any code copied from other projects.

Fill in the release notes towards the bottom of the PR description.
See Release Notes Guidelines for details.

== NO RELEASE NOTE ==

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 16, 2020

CLA Signed

The committers are authorized under a signed CLA.

  • ✅ Vladimirs Kotovs (6c8ad4398f63ddf50dcbfd84b03cb5043cdd75a3)

@rk13
Copy link
Contributor Author

rk13 commented Dec 23, 2020

Rebased PR branch on the latest master

Copy link
Contributor

@rschlussel rschlussel left a comment

Choose a reason for hiding this comment

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

Please squash your second commit into the first.

if (formatContainsHourOfAMPM) {
// At the moment format does not allow to include AM/PM token, thus it was never possible to specify PM hours using 'HH' token in format
// Keep existing behaviour by defaulting to 0(AM) for AMPM_OF_DAY if format string contains 'HH'
builder.parseDefaulting(ChronoField.HOUR_OF_AMPM, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we set all three of the parseDefaultings regardless of whether the format contains hour of AMPM (if a format doesn't have HOUR_OF_AMPM, then this won't be relevant, and similarly for HOUR_OF_DAY if it does have HOUR_OF_AMPM)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, not.
Conflicts can happen if both HOUR_OF_DAY and HOUR_OF_AMPM values provided (e.g. one with parseDefaultings and another in the input).
Example: to_timestamp('1988/04/08 2','yyyy/mm/dd hh') will trigger "Conflict found: HourOfDay 0 differs from HourOfDay 2" error if we set all three of the parseDefaultings

// Append default values(0) for time fields(HH24, HH, MI, SS) because JSR-310 does not accept bare Date value as DateTime

if (formatContainsHourOfAMPM) {
// At the moment format does not allow to include AM/PM token, thus it was never possible to specify PM hours using 'HH' token in format
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason we couldn't or shouldn't support an AM/PM token?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I do not know about any reason why we should not.
Teradata date format arguments support AM/PM actually (https://www.docs.teradata.com/r/~_sY_PYVxZzTnqKq45UXkQ/DlNXnvtMQTAeWXYLHvEarQ).
Original grammar used to tokenise input should be extended in this case
https://github.com/prestodb/presto/blob/master/presto-teradata-functions/src/main/antlr4/com/facebook/presto/teradata/functions/DateFormat.g4
It is better to be implemented in separate PR as a new feature I think.

@rk13 rk13 force-pushed the teradata-migrate-joda branch 2 times, most recently from 63a5fa3 to 3779262 Compare January 7, 2021 15:21
@rk13 rk13 requested a review from rschlussel January 7, 2021 17:25
@ajaygeorge
Copy link
Contributor

@rschlussel Can you please take another look at this PR.

@rk13
Copy link
Contributor Author

rk13 commented Feb 4, 2021

Rebased on the latest master

Copy link
Contributor

@rschlussel rschlussel left a comment

Choose a reason for hiding this comment

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

so sorry forgot to come back to this.

@rschlussel rschlussel merged commit 87e84b2 into prestodb:master Mar 8, 2021
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.

None yet

3 participants