-
Notifications
You must be signed in to change notification settings - Fork 3.6k
add "STORAGE TABLE" and "MATERIALIZED VIEW" type in information_schema.tables #10745
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,9 @@ | |
| import static io.trino.connector.informationschema.InformationSchemaMetadata.defaultPrefixes; | ||
| import static io.trino.connector.informationschema.InformationSchemaMetadata.isTablesEnumeratingTable; | ||
| import static io.trino.metadata.MetadataListing.getViews; | ||
| import static io.trino.metadata.MetadataListing.listMaterializedViews; | ||
| import static io.trino.metadata.MetadataListing.listSchemas; | ||
| import static io.trino.metadata.MetadataListing.listStorageTab; | ||
| import static io.trino.metadata.MetadataListing.listTableColumns; | ||
| import static io.trino.metadata.MetadataListing.listTablePrivileges; | ||
| import static io.trino.metadata.MetadataListing.listTables; | ||
|
|
@@ -280,11 +282,23 @@ private void addTablesRecords(QualifiedTablePrefix prefix) | |
| { | ||
| Set<SchemaTableName> tables = listTables(session, metadata, accessControl, prefix); | ||
| Set<SchemaTableName> views = listViews(session, metadata, accessControl, prefix); | ||
| Set<SchemaTableName> mviews = listMaterializedViews(session, metadata, accessControl, prefix); | ||
| Set<SchemaTableName> storageTables = listStorageTab(session, metadata, accessControl, prefix); | ||
| // TODO (https://github.com/trinodb/trino/issues/8207) define a type for materialized views | ||
|
|
||
| for (SchemaTableName name : union(tables, views)) { | ||
| // if table and view names overlap, the view wins | ||
| String type = views.contains(name) ? "VIEW" : "BASE TABLE"; | ||
| String type = "BASE TABLE"; | ||
| if (views.contains(name)) { | ||
| type = "VIEW"; | ||
| } | ||
| else if (mviews.contains(name)) { | ||
| type = "MATERIALIZE VIEW"; | ||
| } | ||
| else if (storageTables.contains(name)) { | ||
| type = "STORAGE TABLE"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can give a separate type to storage table of MVs unless the ANSI SQL spec for information schema allows it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. base table and mv table is different.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from tables perspective, mv's storage table is a table just as any other table.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It doesn't matter who created a table and why.
i'd suggesting filing up an issue for this to facilitate a discussion. |
||
| } | ||
|
|
||
| addRecord( | ||
| prefix.getCatalogName(), | ||
| name.getSchemaName(), | ||
|
|
||
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 was left as a TODO (see a few lines above https://github.com/trinodb/trino/pull/10745/files#diff-de0b2e0ffdaf5c2eeda3ad7f0513ad28373a158a1f4fbe32ef0a10f5ce10cc73L283) because information schema table is supposed to follow ANSI SQL spec and we didn't have clarity about which table type should be used for MVs if it is to be differentiated from the others.
fyi @sopel39 @findepi @martint
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.
If we want to follow spec, we should return "VIEW" for materialized views.
but let's wait maybe @martint has more thoughts on this.
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.
materialize view and normal view is different, so i think they are different type