-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix bug when querying system.jdbc.tables #4965
Fix bug when querying system.jdbc.tables #4965
Conversation
@@ -36,7 +38,7 @@ private FilterUtil() {} | |||
} | |||
|
|||
Object value = domain.getSingleValue(); | |||
return Optional.of(((Slice) value).toStringUtf8()); | |||
return Optional.of(((Slice) value).toStringUtf8().toLowerCase(ENGLISH)); |
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 is not correct. This method is not dedicated to table/column names, so should not lower case.
Even if it was dedicated, lowercasing would be misleading. (a non-lowercase expected value never matches, when lowercased will)
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 are faster than GHA.
Fixed - moved lowercasing to a different place.
e527598
to
72db624
Compare
presto-tests/src/test/java/io/prestosql/tests/TestMetadataManager.java
Outdated
Show resolved
Hide resolved
@@ -81,8 +82,8 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect | |||
{ | |||
Session session = ((FullConnectorSession) connectorSession).getSession(); | |||
Optional<String> catalogFilter = tryGetSingleVarcharValue(constraint, 0); | |||
Optional<String> schemaFilter = tryGetSingleVarcharValue(constraint, 1); | |||
Optional<String> tableFilter = tryGetSingleVarcharValue(constraint, 2); | |||
Optional<String> schemaFilter = tryGetSingleVarcharValue(constraint, 1).map(filter -> filter.toLowerCase(ENGLISH)); |
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 instead fix the check in the other place to allow non lower cased values? This seems invalid to me to manipulate values given in sql literals.
72db624
to
a9f6f79
Compare
Builder table = InMemoryRecordSet.builder(METADATA); | ||
if (!isLowerCase(schemaFilter) || !isLowerCase(tableFilter)) { | ||
// Uppercase predicate will never match a lowercase name | ||
return table.build().cursor(); |
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 is something to be removed in #17
If we place the logic closer to where it's needed (eg when QualifiedTablePrefix is constructed), then
- it would be more obvious why the check matters
- it would be easier to track it down and remove when doing above issue
Please check automation failures. |
{ | ||
assertThat(queryRunner.execute("SELECT * FROM system.jdbc.tables WHERE TABLE_SCHEM = 'upper_case_schema' AND TABLE_NAME = 'upper_case_table'")) | ||
.hasSize(1); | ||
assertThat(queryRunner.execute("SELECT * FROM system.jdbc.tables WHERE TABLE_SCHEM = 'UPPER_CASE_SCHEMA'")) |
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.
a9f6f79
to
2c1737f
Compare
Making where constraints upper-case caused exception
2c1737f
to
d921455
Compare
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.
Code LGTM, but I would sprinkle it with "TODO" to make the intent and code's contemporary applicability more clear.
presto-main/src/main/java/io/prestosql/connector/system/jdbc/TableJdbcTable.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/connector/system/jdbc/TableJdbcTable.java
Outdated
Show resolved
Hide resolved
presto-tests/src/test/java/io/prestosql/tests/TestMetadataManager.java
Outdated
Show resolved
Hide resolved
…ger.java Co-authored-by: Piotr Findeisen <[email protected]>
…ger.java Co-authored-by: Piotr Findeisen <[email protected]>
…ableJdbcTable.java Co-authored-by: Piotr Findeisen <[email protected]>
…ableJdbcTable.java Co-authored-by: Piotr Findeisen <[email protected]>
…ger.java Co-authored-by: Piotr Findeisen <[email protected]>
Merged as: c336e9a |
Thanks! |
Making where constraints upper-case caused exception