Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,43 +277,34 @@ private void addColumnsRecords(QualifiedTablePrefix prefix)

private void addTablesRecords(QualifiedTablePrefix prefix)
{
boolean needsTableType = requiredColumns.contains("table_type") || requiredColumns.contains("trino_relation_type");
boolean needsTableType = requiredColumns.contains("table_type");
Set<SchemaTableName> relations;
Map<SchemaTableName, RelationType> relationTypes;
Set<SchemaTableName> views;
if (needsTableType) {
relationTypes = getRelationTypes(session, metadata, accessControl, prefix);
Map<SchemaTableName, RelationType> relationTypes = getRelationTypes(session, metadata, accessControl, prefix);
relations = relationTypes.keySet();
views = relationTypes.entrySet().stream()
.filter(entry -> entry.getValue() == RelationType.VIEW)
.map(Entry::getKey)
.collect(toImmutableSet());
}
else {
relations = listTables(session, metadata, accessControl, prefix);
relationTypes = null;
views = Set.of();
}
// TODO (https://github.com/trinodb/trino/issues/8207) define a type for materialized views

for (SchemaTableName name : relations) {
String type = null;
String trinoRelationType = null;
if (needsTableType) {
switch (relationTypes.get(name)) {
case TABLE -> {
type = "BASE TABLE";
trinoRelationType = type;
}
case VIEW -> {
type = "VIEW";
trinoRelationType = type;
}
case MATERIALIZED_VIEW -> {
type = "BASE TABLE";
trinoRelationType = "MATERIALIZED VIEW";
}
}
// if table and view names overlap, the view wins
type = views.contains(name) ? "VIEW" : "BASE TABLE";
}
addRecord(
prefix.getCatalogName(),
name.getSchemaName(),
name.getTableName(),
type,
trinoRelationType,
null);
if (isLimitExhausted()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public enum InformationSchemaTable
.column("table_schema", createUnboundedVarcharType())
.column("table_name", createUnboundedVarcharType())
.column("table_type", createUnboundedVarcharType())
.hiddenColumn("trino_relation_type", createUnboundedVarcharType())
.hiddenColumn("table_comment", createUnboundedVarcharType()) // MySQL compatible
.build()),
VIEWS(table("views")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1052,15 +1052,15 @@ public void testMaterializedView()
.containsAll("VALUES '" + view.getObjectName() + "'");
// information_schema.tables without table_name filter so that ConnectorMetadata.listViews is exercised
assertThat(query(
"SELECT table_name, table_type, trino_relation_type FROM information_schema.tables " +
"SELECT table_name, table_type FROM information_schema.tables " +
"WHERE table_schema = '" + view.getSchemaName() + "'"))
.skippingTypesCheck()
.containsAll("VALUES ('" + view.getObjectName() + "', 'BASE TABLE', 'MATERIALIZED VIEW')");
.containsAll("VALUES ('" + view.getObjectName() + "', 'BASE TABLE')");
// information_schema.tables with table_name filter
assertQuery(
"SELECT table_name, table_type, trino_relation_type FROM information_schema.tables " +
"SELECT table_name, table_type FROM information_schema.tables " +
"WHERE table_schema = '" + view.getSchemaName() + "' and table_name = '" + view.getObjectName() + "'",
"VALUES ('" + view.getObjectName() + "', 'BASE TABLE', 'MATERIALIZED VIEW')");
"VALUES ('" + view.getObjectName() + "', 'BASE TABLE')");

// system.jdbc.tables without filter
assertThat(query("SELECT table_schem, table_name, table_type FROM system.jdbc.tables"))
Expand Down