-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add TestMemSqlDistributedQueries and implement gaps #5495
Add TestMemSqlDistributedQueries and implement gaps #5495
Conversation
i merged type mapping test, please rebase. |
Seems like MemSql tests were skipped. https://github.com/prestosql/presto/runs/1231980668?check_suite_focus=true#step:5:1 Will rebase. |
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 had some questions and have added them as comments.
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/test/java/io/prestosql/plugin/memsql/TestMemSqlDistributedQueries.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/test/java/io/prestosql/plugin/memsql/TestMemSqlDistributedQueries.java
Outdated
Show resolved
Hide resolved
@Override | ||
public void testLargeIn() | ||
{ | ||
// TODO Caused by: java.sql.SQLException: Thread stack overrun: Used: 1048713 of a 1048576 stack. Use 'memsqld --thread_stack=#' to specify a bigger stack if needed. |
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 opted to skip this test instead of modifying the test container since I don't think there's any point in making this test pass if it will actually fail in practice for most people.
presto-memsql/src/test/java/io/prestosql/plugin/memsql/TestMemSqlIntegrationSmokeTest.java
Show resolved
Hide resolved
@@ -95,7 +106,8 @@ private static DataTypeTest singlePrecisionFloatingPointTests(DataType<Float> fl | |||
// we are not testing Nan/-Infinity/+Infinity as those are not supported by MemSQL | |||
return DataTypeTest.create() | |||
.addRoundTrip(floatType, 3.14f) | |||
// .addRoundTrip(floatType, 3.1415927f) // Overeagerly rounded by MemSQL to 3.14159 TODO | |||
// TODO Overeagerly rounded by MemSQL to 3.14159 |
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.
This seems to be due to MemSQL's FLOAT type having low precision rather than rounding errors.
{ | ||
jsonTestCases(jsonDataType(value -> "JSON " + formatStringLiteral(value))) | ||
.execute(getQueryRunner(), prestoCreateAsSelect("presto_test_json")); | ||
// TODO MemSQL doesn't support CAST to JSON but accepts string literals as JSON values |
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.
CAST to JSON doesn't exist. There's a TO_JSON function but that parses strings into JSON values. ie. strings get converted into double quoted JSON strings. Passing strings that are valid JSON seem to get parsed into JSON during INSERT.
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.
Having comment is good, but this shouldn't be a TODO, because that's nor our problem.
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
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.
early feedback
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Outdated
Show resolved
Hide resolved
presto-memsql/src/main/java/io/prestosql/plugin/memsql/MemSqlClient.java
Show resolved
Hide resolved
@findepi AC. |
switch (typeHandle.getJdbcType()) { | ||
case Types.VARCHAR: | ||
VarcharType varcharType = (columnSize <= VarcharType.MAX_LENGTH) ? createVarcharType(columnSize) : createUnboundedVarcharType(); | ||
// Remote database can be case insensitive. |
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.
can we know if it is and react accordingly?
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.
We can fire a query to test the easy cases (eg A = a
) but it is possible for such checks to pass for ASCII characters but fail for unicode characters (eg. S = ß
) depending on the collation used by the remote database.
I'm working on adding a smoke test to at-least verify that such-cases are caught in tests.
public PreparedStatement getPreparedStatement(Connection connection, String sql) | ||
throws SQLException | ||
{ | ||
return connection.prepareStatement(sql); |
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.
Override seems redundant?
else if (varcharType.getBoundedLength() <= 65535) { | ||
dataType = "text"; | ||
} | ||
else if (varcharType.getBoundedLength() <= 16777215) { | ||
dataType = "mediumtext"; |
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.
define constatns for these numbers, like you did for MEMSQL_VARCHAR_MAX_LENGTH
return WriteMapping.sliceMapping(dataType, varcharWriteFunction()); | ||
} | ||
if (VARBINARY.equals(type)) { | ||
return WriteMapping.sliceMapping("mediumblob", varbinaryWriteFunction()); |
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.
medium or longblob?
return WriteMapping.longMapping("datetime", timestampWriteFunction(TIMESTAMP_MILLIS)); | ||
} | ||
|
||
return super.toWriteMapping(session, type); |
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.
// TODO add explicit mappings
} | ||
|
||
@Override | ||
public void renameTable(JdbcIdentity identity, JdbcTableHandle handle, SchemaTableName newTableName) |
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.
move this above renameColumn
(ideally, keep order as in superclass)
return dataType("date", DATE, toLiteral, identity()); | ||
} | ||
|
||
private static DataType<String> memSqlJsonDataType(Function<String, String> toLiteral) |
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.
please do the rename jsonDataType -> memSqlJsonDataType
in the commit which intro'd the function
return Optional.empty(); | ||
} | ||
return super.filterColumnNameTestData(columnName); | ||
return nullToEmpty(exception.getMessage()).matches(".*(Incorrect column name).*"); |
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.
braces in the pattern are redundant.
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata) | ||
{ | ||
// MemSQL doesn't accept `some;column` in CTAS statements - so we explicitly block it and throw a proper error message | ||
// TODO figure out how to quote ; in column names |
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.
let's remove the TODO. I wouldn't spent time on it
same for copyTableSchema
.findAny(); | ||
if (illegalColumnName.isPresent()) { |
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.
you can get away without an assigment
.findAny()
.ifPresent(illegalColumnName -> {
throw ...
same in the other method
{ | ||
// MemSQL doesn't accept `some;column` in CTAS statements - so we explicitly block it and throw a proper error message | ||
// TODO figure out how to quote ; in column names | ||
Optional<String> illegalColumnName = columnNames.stream().filter(s -> s.contains(";")).findAny(); |
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.
break the line before .filter and .findAny
@findepi AC. |
Thanks! |
Fixes #5369.