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

Support TIMESTAMPS with precisions higher than 3 in MySQL #8060

Merged
merged 1 commit into from
Jun 28, 2021

Conversation

guyco33
Copy link
Member

@guyco33 guyco33 commented May 24, 2021

Solves #6910
Fixes #7413

@guyco33
Copy link
Member Author

guyco33 commented May 26, 2021

@findepi, PR ready to review

@findepi
Copy link
Member

findepi commented May 31, 2021

cc @hashhar @losipiuk @wendigo

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @guyco33. The impl looks good % Piotr's comments.

The tests can use more cases. Most of the tested values have trailing 0s - you can copy the values from PostgreSQL tests.

Some values don't round-trip and it's a known issue (#7201 (comment)) - don't "fix" those test values - leave them be. They should be fixed only after the DST handling gets fixed.

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Some comments. Sorry for the delay @guyco33.

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

good job!

* @see #testTimestampFromTrino
*/
@Test
public void testTimestampCoercion()
Copy link
Member Author

Choose a reason for hiding this comment

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

copied from PostgreSQL

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Looks good, some comments.

@guyco33
Copy link
Member Author

guyco33 commented Jun 17, 2021

@hashhar, in ece6e6e I removed duplicate tests, reorder them and change 0s values to contain higher precision

@guyco33 guyco33 force-pushed the fix_6910 branch 3 times, most recently from b926b45 to 1c58ab8 Compare June 21, 2021 13:02
@@ -605,88 +594,75 @@ public void testTimestampFromMySql(ZoneId sessionZone)
// before epoch (MySQL's timestamp type doesn't support values <= epoch)
//.addRoundTrip("timestamp(3)", "TIMESTAMP '1958-01-01 13:18:03.123'", createTimestampType(3), "TIMESTAMP '1958-01-01 13:18:03.000'")
Copy link
Member

Choose a reason for hiding this comment

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

is this comment outdated?
i see test values like 1969-12-31 23:59:59.1230001, which is before epoch

Copy link
Member Author

Choose a reason for hiding this comment

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

Mysql timestamp type is not supporting negative epoch

Copy link
Member

Choose a reason for hiding this comment

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

i understand now:

  • we're testing negative epoch when we insert with MySQL datetime, eg
    // negative epoch
    .addRoundTrip("datetime(6)", "TIMESTAMP '1969-12-31 23:59:59.999995'", createTimestampType(6), "TIMESTAMP '1969-12-31 23:59:59.999995'")
    
  • we cannot test roundtrip when inserting with MySQL timestamp, because it doesn't support negative epoch
  • we should be able to test roundtrip when CT/CTAS with Trino, because Trino timestamp is mapped to datetime

is there a test for last bullet?

Copy link
Member Author

@guyco33 guyco33 Jun 23, 2021

Choose a reason for hiding this comment

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

is there a test for last bullet?

Yes we have it in testTimestampCoercion L639 and L676:L679 and also in testTimestampFromTrino L601 and L609

Comment on lines 602 to 614
// epoch (MySQL's timestamp type doesn't support values <= epoch)
//.addRoundTrip("timestamp(3)", "TIMESTAMP '1970-01-01 00:00:00.000'", createTimestampType(3), "TIMESTAMP '1970-01-01 00:00:00.000'")
Copy link
Member

Choose a reason for hiding this comment

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

is this comment outdated?
i see test values like 1969-12-31 23:59:59.1230001, which is before epoch

Copy link
Member Author

@guyco33 guyco33 Jun 22, 2021

Choose a reason for hiding this comment

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

It's not outdated. Mysql timestamp type doesn't support negative epoch. Maybe we can completely remove it since it's not a valid Mysql input value.

//.addRoundTrip("timestamp(3)", "TIMESTAMP '1970-01-01 00:00:00.000'", createTimestampType(3), "TIMESTAMP '1970-01-01 00:00:00.000'")
.addRoundTrip("timestamp(3)", "TIMESTAMP '1970-01-01 00:13:42.000'", TIMESTAMP_MILLIS, "TIMESTAMP '1970-01-01 00:13:42.000'")
.addRoundTrip("timestamp(3)", "TIMESTAMP '2018-04-01 02:13:55.123'", TIMESTAMP_MILLIS, "TIMESTAMP '2018-04-01 02:13:55.123'")
//.addRoundTrip("timestamp(3)", "TIMESTAMP '1970-01-01 00:00:00.000'", createTimestampType(3), "TIMESTAMP '1970-01-01 01:00:00.000'")
Copy link
Member

Choose a reason for hiding this comment

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

undesired change on this line (hour 00 -> 01). please revert.

Copy link
Member Author

Choose a reason for hiding this comment

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

1970-01-01 00:00:00 is not a valid value for Mysql timestamp type.
It has a range of 1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
https://dev.mysql.com/doc/refman/8.0/en/datetime.html#:~:text=MySQL%20retrieves%20and%20displays%20DATETIME,%3A14%3A07'%20UTC.
I will remove it from tests as all other comments and unsupported Mysql input values

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

LGTM % comments.

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

LGTM.

@guyco33
Copy link
Member Author

guyco33 commented Jun 27, 2021

@findepi It's ready to merge from my side

@hashhar hashhar merged commit 48519ff into trinodb:master Jun 28, 2021
@hashhar
Copy link
Member

hashhar commented Jun 28, 2021

Thanks a lot for working on this @guyco33 . Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

MySQL connector stopped pushdown TIMESTAMP filters
3 participants