Use timestamp precision 3 in CTAS in MySQL#7166
Conversation
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
hashhar
left a comment
There was a problem hiding this comment.
Thansk for the test method renames. It's much clearer now.
Some changes requested.
There was a problem hiding this comment.
Move this comment into the javadoc now. And change into the above to testTimestampFromTrino.
There was a problem hiding this comment.
Based on this comment, I've dropped this comment entirely. We don't need it to remind us that we'll need more tests when we support more precisions.
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
If I am reading correctly, this would only write TIMESTAMP(3) as datetime(3) and fallback to legacy write mapping for other types (which doesn't have a mapping for TIMESTAMP type at all so throwing an "Unsupported column type" error).
Let's change this branch to run for anything that is a TimestampType and try to see if we can write as timestamp(p) where p is the precision obtained from the type. See SqlServerClient for reference.
There was a problem hiding this comment.
That's a relatively straightforward change. I was comparing to create table instead of insert, but that way makes more sense.
There was a problem hiding this comment.
On second thought, I think this way might be better, especially if we fix #6910 any time soon.
It doesn't really make sense for CTAS to allow more precisions than INSERT, so I think we should always write as DATETIME(3) until #6910.
That leaves us with the option to automatically convert all TIMESTAMPs to precision 3 before inserting on CTAS, but I think that rejecting them is a less surprising behavior, especially if we're soon going to change it to allow other precisions soon.
There was a problem hiding this comment.
This is definitely correct change. @hashhar note that other timesamps with other precision are simply not supported here and cannot be created at all
There was a problem hiding this comment.
Thanks for catching this @jirassimok and @findepi . I missed that CTAS flow differs from INSERT.
I'll fix it in #6910 .
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
0c69010 to
8f58db6
Compare
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I don't think it will be reusable, unless MySQL supports picosecond precision
There was a problem hiding this comment.
"Reuse" is the wrong word here.
Since we separated these tests into their own method, I think this comment is probably unnecessary. We'll need to add more tests when we support more precisions, which is all that this comment is saying now.
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
This is definitely correct change. @hashhar note that other timesamps with other precision are simply not supported here and cannot be created at all
- Separate tests that insert timestamps with Trino from tests that insert from MySQL - Move the Trino-insert tests after the MySQL-insert tests - Rename the timestamp test methods to state how they insert data
8f58db6 to
9a18806
Compare
hashhar
left a comment
There was a problem hiding this comment.
LGTM % leftover TODO comment.
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
Outdated
Show resolved
Hide resolved
9a18806 to
2f2c19e
Compare
|
Do we have the same problem for MemSQL? |
Yes; I'm looking into it. |
This addresses #6909.
The first two commits are minor refactors to the MySql timestamp tests so they are organized in a way that separates CTAS failures from other failures.