Skip to content
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

Conversation

findepi
Copy link
Member

@findepi findepi commented Jul 19, 2023

In the absence of explicit documentation, the use place
(io.trino.metadata.MetadataManager#listTableColumns) defines
streamTableColumns contract as covering tables only. This PR 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.

@findepi findepi added the no-release-notes This pull request does not require release notes entry label Jul 19, 2023
@cla-bot cla-bot bot added the cla-signed label Jul 19, 2023
@findepi
Copy link
Member Author

findepi commented Jul 19, 2023

no-release-notes because I think that io.trino.metadata.MetadataManager#listTableColumns hides the erroneous impl.

@findepi findepi force-pushed the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch from e91798b to 9c2b5fc Compare July 19, 2023 11:59
@github-actions github-actions bot added tests:hive hive Hive connector labels Jul 19, 2023
@@ -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
Copy link
Member Author

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

if (viewCache.containsKey(table) || materializedViewCache.containsKey(table)) {
throw new TableNotFoundException(table);

if (isPrestoView(parameters) && isHiveOrPrestoView(getTableType(table))) {
// this is a Presto Hive view, hence not a table
throw new TableNotFoundException(getSchemaTableName());

@findepi findepi force-pushed the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch from 9c2b5fc to 3ca488b Compare July 19, 2023 21:06
@findepi findepi requested a review from sopel39 July 19, 2023 21:09
@findepi findepi force-pushed the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch from 3ca488b to e4dc189 Compare July 20, 2023 07:50
@ebyhr
Copy link
Member

ebyhr commented Jul 20, 2023

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);
Copy link
Member

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

Copy link
Member Author

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?

@findepi findepi force-pushed the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch from e4dc189 to 3397157 Compare July 20, 2023 11:20
findepi added 4 commits July 20, 2023 14:32
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.
@findepi findepi force-pushed the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch from 3397157 to 5a7cd36 Compare July 20, 2023 12:32
findepi added 2 commits July 20, 2023 14:43
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.
@findepi findepi force-pushed the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch from 5a7cd36 to e4ecb16 Compare July 20, 2023 12:43
@findepi findepi merged commit dc46f57 into trinodb:master Jul 20, 2023
@findepi findepi deleted the findepi/fix-hivemetadata-streamtablecolumns-not-to-include-views-1f2f2f branch July 20, 2023 19:42
@github-actions github-actions bot added this to the 423 milestone Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed hive Hive connector no-release-notes This pull request does not require release notes entry
Development

Successfully merging this pull request may close these issues.

4 participants