Convert TestMemSqlTypeMapping to use SqlDataTypeTest#7202
Convert TestMemSqlTypeMapping to use SqlDataTypeTest#7202Atema wants to merge 7 commits intotrinodb:masterfrom Atema:convert-testmemsqltypemapping
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
Very cool! I guess your intention is to keep those contributions somewhat separate (instead of squashing into single commit, with You can also prefer to put up 5 separate PRs. Of course they would be conflicts, so we would need to review them one by one. Or, I review this as is, let me know your preference. |
|
All of us are fine with reviewing as a whole, and squashing the commits together! |
|
@martint can you please help with the CLA verification here? |
There was a problem hiding this comment.
Looks good to me. Requested a few changes in decimalTests (test for NULL is missing) and rest of it are editorial comments.
The SqlDataTypeTest failure with REAL seems concerning but it's not the tests fault, most likely some issue with toWriteMapping used for REAL (or MemSQL itself).
| .addRoundTrip(decimalDataType(38, 0), new BigDecimal("27182818284590452353602874713526624977")) | ||
| .addRoundTrip(decimalDataType(38, 0), new BigDecimal("-27182818284590452353602874713526624977")); | ||
| return SqlDataTypeTest.create() | ||
| .addRoundTrip("decimal(3, 0)", "CAST('193' AS decimal(3, 0))", createDecimalType(3, 0), "CAST('193' AS decimal(3, 0))") |
There was a problem hiding this comment.
Can you add a test where we try writing NULL into a decimal(3, 0) and another where we write NULL into a decimal(38, 0)?
| .addRoundTrip("char(1)", "'a'", createCharType(1), "CAST('a' AS char(1))") | ||
| .addRoundTrip("char(8)", "'abc'", createCharType(8), "CAST('abc' AS char(8))") | ||
| .addRoundTrip("char(8)", "'12345678'", createCharType(8), "CAST('12345678' AS char(8))") | ||
| .addRoundTrip("char(255)", String.format("'%s'", "a".repeat(255)), createCharType(255), String.format("CAST('%s' AS char(255))", "a".repeat(255))); |
There was a problem hiding this comment.
nit: Add static import for String.format.
| .addRoundTrip(varcharDataType(20000, CHARACTER_SET_UTF8), sampleUnicodeText) | ||
| String sampleUnicodeText = "'\u653b\u6bbb\u6a5f\u52d5\u968a'"; | ||
| SqlDataTypeTest.create() | ||
| .addRoundTrip("tinytext " + CHARACTER_SET_UTF8, sampleUnicodeText, createVarcharType(255), "CAST(" + sampleUnicodeText + "AS varchar(255))") |
There was a problem hiding this comment.
nit: missing whitespace before AS inside quotes.
| .addRoundTrip("tinytext " + CHARACTER_SET_UTF8, sampleUnicodeText, createVarcharType(255), "CAST(" + sampleUnicodeText + "AS varchar(255))") | |
| .addRoundTrip("tinytext " + CHARACTER_SET_UTF8, sampleUnicodeText, createVarcharType(255), "CAST(" + sampleUnicodeText + " AS varchar(255))") |
| .addRoundTrip(dateDataType, dateOfLocalTimeChangeForwardAtMidnightInJvmZone) | ||
| .addRoundTrip(dateDataType, dateOfLocalTimeChangeForwardAtMidnightInSomeZone) | ||
| .addRoundTrip(dateDataType, dateOfLocalTimeChangeBackwardAtMidnightInSomeZone); | ||
| for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), jvmZone.getId(), someZone.getId())) { |
There was a problem hiding this comment.
This loop works but for future reference take a look at PostgresqlTypeMappingTest to see how it uses DataProvider. The benefit is that if a test fails you can know exactly which timezone it failed for rather than having to guess which iteration of the loop it failed in.
No change requested since it's pre-existing. Can be a follow up.
| return new CreateAndInsertDataSetup(memSqlServer::execute, tableNamePrefix); | ||
| } | ||
|
|
||
| private static DataType<LocalDate> memSqlDateDataType(Function<LocalDate, String> toLiteral) |
| .addRoundTrip("smallint", "32456", SMALLINT, "SMALLINT '32456'") | ||
| .addRoundTrip("tinyint", "125", TINYINT, "TINYINT '125'") | ||
| .addRoundTrip("double", "123.45", DOUBLE, "DOUBLE '123.45'") | ||
| // TODO: Real doesn't work with SqlDataTypeTest (see below) |
There was a problem hiding this comment.
| // TODO: Real doesn't work with SqlDataTypeTest (see below) | |
| // TODO: fails in SqlDataTypeTest#verifyPredicate |
There was a problem hiding this comment.
Same change in the comment in testFloat too.
| .addRoundTrip(memSqlFloatDataType(), null) | ||
| .execute(getQueryRunner(), memSqlCreateAndInsert("tpch.memsql_test_float")); | ||
|
|
||
| // TODO: Changing to SqlDataTypeTest with Real does not work: assertion in SqlDataTypeTest.verifyPredicate() fails |
There was a problem hiding this comment.
Remove the commented code. And move the TODO to the start of the function.
- Remove commented code & change comment - Add whitespae before AS - Add static String.format - Add NULL cases for decimal
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
|
@hashhar Thanks for the comments. I've pushed the requested changes |
hashhar
left a comment
There was a problem hiding this comment.
Looks good to be merged % the REAL data-type issue with verifyPredicate.
The issue with REAL type mapping is pre-existing so we can tackle that in a follow-up IMO.
| .addRoundTrip(varcharDataType(sampleUnicodeText.length(), CHARACTER_SET_UTF8), sampleUnicodeText) | ||
| .addRoundTrip(varcharDataType(32, CHARACTER_SET_UTF8), sampleUnicodeText) | ||
| .addRoundTrip(varcharDataType(20000, CHARACTER_SET_UTF8), sampleUnicodeText) | ||
| String sampleUnicodeText = "'\u653b\u6bbb\u6a5f\u52d5\u968a'"; |
There was a problem hiding this comment.
nit: rename it to sampleUnicodeLiteral since the ' are not actually part of the tested text.
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
|
@martint can you please help with the CLA verification here? |
plugin/trino-memsql/src/test/java/io/trino/plugin/memsql/TestMemSqlTypeMapping.java
Show resolved
Hide resolved
|
@martint can you please help with the CLA here? |
|
@cla-bot check |
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
|
The cla-bot has been summoned, and re-checked this pull request! |
Confirmed that it's product bug in MySQL and MemSQL connectors. Filed #9998 |
|
Merged this commit in #10296. Thanks! |
Hej, we* did our best to resolve issue #6393 by converting the test in class
testMemSqlTypeMappingto useSqlDataTypeTestinstead ofDataTypeTest.We have succeeded on most methods, with one exception being the Real type (both in
testBasicType()andtestFloat(), which resulted in the exception below. I don't know where exactly it stems from, but I believe it may be worth further investigation.Let me know if you have any questions/comments.
* We are a group of five students (me, @caillouc, @hallon-heyman, @linnea-bonnevier, and @aoutir) who worked on this issue as a university assignment. All of us have sent in the CLA, and the ownership of the contributed code is personal.
Fixes #6393