|
25 | 25 | import com.facebook.presto.spi.SchemaTableName;
|
26 | 26 | import com.facebook.presto.spi.connector.ConnectorTransactionHandle;
|
27 | 27 | import com.facebook.presto.spi.security.AccessControl;
|
| 28 | +import com.google.common.collect.ImmutableSet; |
28 | 29 |
|
29 | 30 | import javax.inject.Inject;
|
30 | 31 |
|
31 | 32 | import java.util.Optional;
|
| 33 | +import java.util.Set; |
32 | 34 |
|
33 | 35 | import static com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType;
|
34 | 36 | import static com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession;
|
@@ -88,15 +90,19 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect
|
88 | 90 | for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
|
89 | 91 | QualifiedTablePrefix prefix = tablePrefix(catalog, schemaFilter, tableFilter);
|
90 | 92 |
|
91 |
| - if (FilterUtil.emptyOrEquals(typeFilter, "TABLE")) { |
92 |
| - for (SchemaTableName name : listTables(session, metadata, accessControl, prefix)) { |
93 |
| - table.addRow(tableRow(catalog, name, "TABLE")); |
| 93 | + Set<SchemaTableName> views = ImmutableSet.of(); |
| 94 | + if (FilterUtil.emptyOrEquals(typeFilter, "VIEW")) { |
| 95 | + views = ImmutableSet.copyOf(listViews(session, metadata, accessControl, prefix)); |
| 96 | + for (SchemaTableName name : views) { |
| 97 | + table.addRow(tableRow(catalog, name, "VIEW")); |
94 | 98 | }
|
95 | 99 | }
|
96 | 100 |
|
97 |
| - if (FilterUtil.emptyOrEquals(typeFilter, "VIEW")) { |
98 |
| - for (SchemaTableName name : listViews(session, metadata, accessControl, prefix)) { |
99 |
| - table.addRow(tableRow(catalog, name, "VIEW")); |
| 101 | + if (FilterUtil.emptyOrEquals(typeFilter, "TABLE")) { |
| 102 | + for (SchemaTableName name : listTables(session, metadata, accessControl, prefix)) { |
| 103 | + if (!views.contains(name)) { |
| 104 | + table.addRow(tableRow(catalog, name, "TABLE")); |
| 105 | + } |
100 | 106 | }
|
101 | 107 | }
|
102 | 108 | }
|
|
0 commit comments