Skip to content

Commit 2802539

Browse files
committed
ignore temporary tables
1 parent 998379d commit 2802539

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ private void getNames(Node node, ImmutableSet.Builder<QualifiedName> tableBuilde
345345
case SetSchemaAuthorization s -> setCatalogAndSchemaNameFromSchemaQualifiedName(Optional.of(s.getSource()), catalogBuilder, schemaBuilder, catalogSchemaBuilder);
346346
case SetTableAuthorization s -> tableBuilder.add(qualifyName(s.getSource()));
347347
case SetViewAuthorization s -> tableBuilder.add(qualifyName(s.getSource()));
348-
case Table s -> tableBuilder.add(qualifyName(s.getName()));
348+
case Table s -> {
349+
// ignore temporary tables as they can have various table parts
350+
if (!temporaryTables.contains(s.getName())) {
351+
tableBuilder.add(qualifyName(s.getName()));
352+
}
353+
}
349354
case TableFunctionInvocation s -> tableBuilder.add(qualifyName(s.getName()));
350355
case WithQuery withQuery -> temporaryTables.add(QualifiedName.of(withQuery.getName().getValue()));
351356
default -> {}
@@ -396,11 +401,6 @@ private QualifiedName qualifyName(QualifiedName table)
396401
{
397402
List<String> tableParts = table.getParts();
398403

399-
// ignore temporary tables created by WITH clause as they can have various table parts
400-
if (temporaryTables.contains(table)) {
401-
return table;
402-
}
403-
404404
return switch (tableParts.size()) {
405405
case 1 -> QualifiedName.of(defaultCatalog.orElseThrow(this::unsetDefaultExceptionSupplier), defaultSchema.orElseThrow(this::unsetDefaultExceptionSupplier), tableParts.getFirst());
406406
case 2 -> QualifiedName.of(defaultCatalog.orElseThrow(this::unsetDefaultExceptionSupplier), tableParts.getFirst(), tableParts.get(1));

gateway-ha/src/test/java/io/trino/gateway/ha/router/TestRoutingGroupSelector.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ uno as (SELECT c1 FROM dos)
422422

423423
Set<QualifiedName> tablesWithDefaults = trinoQueryPropertiesWithDefaults.getTables();
424424
assertThat(tablesWithDefaults).containsExactlyInAnyOrder(
425-
QualifiedName.of("uno"),
426-
QualifiedName.of("dos"),
427425
QualifiedName.of("cat", "schem", "tbl1")
428426
);
429427

@@ -433,8 +431,6 @@ uno as (SELECT c1 FROM dos)
433431
TrinoQueryProperties trinoQueryPropertiesNoDefaults = new TrinoQueryProperties(mockRequestNoDefaults, requestAnalyzerConfig);
434432
Set<QualifiedName> tablesNoDefaults = trinoQueryPropertiesNoDefaults.getTables();
435433
assertThat(tablesNoDefaults).containsExactlyInAnyOrder(
436-
QualifiedName.of("uno"),
437-
QualifiedName.of("dos"),
438434
QualifiedName.of("cat", "schem", "tbl1")
439435
);
440436
}

0 commit comments

Comments
 (0)