-
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 HiveMetadata.streamTableColumns not to include views #18343
Fix HiveMetadata.streamTableColumns not to include views #18343
Conversation
|
e91798b
to
9c2b5fc
Compare
@@ -837,6 +842,7 @@ private Stream<TableColumnsMetadata> streamTableColumns(ConnectorSession session | |||
return Stream.empty(); | |||
} | |||
catch (TableNotFoundException e) { | |||
// it is not a table (e.g. it's a view) (TODO remove exception-driven logic for this case) OR |
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.
re TODO -- FWIW this is how Iceberg does this
trino/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java
Lines 332 to 333 in 9e6cc47
if (viewCache.containsKey(table) || materializedViewCache.containsKey(table)) { | |
throw new TableNotFoundException(table); |
Lines 87 to 89 in f838546
if (isPrestoView(parameters) && isHiveOrPrestoView(getTableType(table))) { | |
// this is a Presto Hive view, hence not a table | |
throw new TableNotFoundException(getSchemaTableName()); |
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Show resolved
Hide resolved
9c2b5fc
to
3ca488b
Compare
3ca488b
to
e4dc189
Compare
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Show resolved
Hide resolved
CI hit #11344 |
@@ -614,7 +615,18 @@ private ConnectorTableMetadata doGetTableMetadata(ConnectorSession session, Sche | |||
throw new TrinoException(UNSUPPORTED_TABLE_TYPE, format("Not a Hive table '%s'", tableName)); | |||
} | |||
|
|||
if (!translateHiveViews && isHiveOrPrestoView(table)) { | |||
boolean isTrinoView = isPrestoView(table); |
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.
It would be nice rename the method too
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.
agreed, but obviously out of scope for this PR, right?
e4dc189
to
3397157
Compare
The test was passing for `AbstractTestHiveLocal` because the test view was never created, so `streamTableColumns` couldn't return anything for it.
…ain path It's up to a subclass to configure connector in some way.
3397157
to
5a7cd36
Compare
In the absence of explicit documentation, the use place (`io.trino.metadata.MetadataManager#listTableColumns`) defines `streamTableColumns` contract as covering tables only. This commit also supplements explicit documentation in `ConnectorMetadata`. This relates to a logic introduced in `HiveMetadata.doGetTableMetadata` in aafe479 commit. It was practical for hive views and when view translation is not enabled, but was not correct for trino views.
5a7cd36
to
e4ecb16
Compare
In the absence of explicit documentation, the use place
(
io.trino.metadata.MetadataManager#listTableColumns
) definesstreamTableColumns
contract as covering tables only. This PR alsosupplements explicit documentation in
ConnectorMetadata
.This relates to a logic introduced in
HiveMetadata.doGetTableMetadata
in aafe479 commit. It was practical for
hive views and when view translation is not enabled, but was not correct
for trino views.