-
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
Support Mixed Case Pinot Tables #7630
Conversation
TODO: adding tests. |
7bd7758
to
393735f
Compare
3e65426
to
dd1789b
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.
Some initial comments.
But I have concerns about the implementation so I didn't review the entire PR. The current implementation ties the remote name cache to the metadata cache and doesn't provide a way to disable the case-insensitive matching which will lead to failures when a Pinot catalog contains colliding table names without any solution other than renaming the offending tables (which may not always be possible).
I'd recommend something similar to how it's implemented in trino-base-jdbc
- look at BaseJdbcClient#toRemoteTableName
usages.
There's a separate cache that maps Trino table names (i.e. always lowercase) to the actual name in the remote system. This cache is used or not depending on a config so that the feature can be disabled.
// Pinot does not support array literals | ||
if (((PinotColumnHandle) entry.getKey()).getDataType() instanceof ArrayType) { | ||
// Pinot does not fully support varbinary null literals (empty byte array): https://github.com/apache/pinot/issues/4230 |
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 have a test detect this when this gets fixed on Pinot side? e.g. asserting that incorrect results are returned for filter on a varbinary columns with an actually empty array and a null value?
} | ||
catch (TableNotFoundException e) { | ||
log.debug(e, "Table not found: %s", tableName); | ||
String pinotTableName = pinotClient.getPinotTableNameFromTrinoTableNameIfExists(tableName.getTableName()); |
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.
nit: It might be helpful to use a name like toRemoteTableName
and toRemoteSchemaName
since many other connectors use those method names and it'll make it easier for readers to figure out what this is trying to do.
I don't have a strong opinion on this though.
@@ -187,11 +177,11 @@ public ConnectorTableMetadata getTableMetadata(ConnectorSession session, Connect | |||
@Override | |||
public List<SchemaTableName> listTables(ConnectorSession session, Optional<String> schemaNameOrNull) | |||
{ | |||
ImmutableList.Builder<SchemaTableName> builder = ImmutableList.builder(); | |||
for (String table : getPinotTableNames()) { | |||
ImmutableSet.Builder<SchemaTableName> builder = ImmutableSet.builder(); |
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.
Won't this silently swallow colliding 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.
Yes, I will push an update shortly that returns colliding table names. It is based off of #9098.
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.
Pushed. This is based off of #9098
dd1789b
to
75575c6
Compare
75575c6
to
79dc0b5
Compare
Rebased off of #9781 . |
4edf88a
to
6180aa9
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.
Looked at last commit since others were merged in #9781.
Is it possible to make this controlled via a toggle? That way once quoted-identifiers are supported it'll be much easier to migrate to that instead of having to hunt the code for places which would need changing.
Also, some named abstraction for Pinot name would be helpful to indicate which places in code expect Trino names vs Pinot names. This became very confusing in Jdbc based connectors in the past.
plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java
Show resolved
Hide resolved
@@ -239,9 +256,14 @@ public GetTables(@JsonProperty("tables") List<String> tables) | |||
} | |||
} | |||
|
|||
public List<String> getAllTables() | |||
protected ListMultimap<String, String> getAllTables() |
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.
Declare as Multimap
even if impl is ListMultimap
.
plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java
Show resolved
Hide resolved
plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/AbstractPinotIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/AbstractPinotIntegrationSmokeTest.java
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.
LGTM % comments.
plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/AbstractPinotIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MockPinotClient.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.
Thanks. I'll merge once CI is done.
Extracted from the pinot insert pr.
Fixes #6789