use of io.trino.spi.eventlistener.TableInfo in project trino by trinodb.
the class TestEventListenerBasic method testReferencedTablesWithMaterializedViews.
@Test
public void testReferencedTablesWithMaterializedViews() throws Exception {
runQueryAndWaitForEvents("SELECT test_column FROM mock.default.test_materialized_view", 2);
QueryCompletedEvent event = getOnlyElement(generatedEvents.getQueryCompletedEvents());
List<TableInfo> tables = event.getMetadata().getTables();
assertThat(tables).hasSize(2);
TableInfo table = tables.get(0);
assertThat(table.getCatalog()).isEqualTo("tpch");
assertThat(table.getSchema()).isEqualTo("tiny");
assertThat(table.getTable()).isEqualTo("nation");
assertThat(table.getAuthorization()).isEqualTo("alice");
assertThat(table.isDirectlyReferenced()).isFalse();
assertThat(table.getFilters()).isEmpty();
assertThat(table.getColumns()).hasSize(1);
ColumnInfo column = table.getColumns().get(0);
assertThat(column.getColumn()).isEqualTo("nationkey");
assertThat(column.getMasks()).isEmpty();
table = tables.get(1);
assertThat(table.getCatalog()).isEqualTo("mock");
assertThat(table.getSchema()).isEqualTo("default");
assertThat(table.getTable()).isEqualTo("test_materialized_view");
assertThat(table.getAuthorization()).isEqualTo("user");
assertThat(table.isDirectlyReferenced()).isTrue();
assertThat(table.getFilters()).isEmpty();
assertThat(table.getColumns()).hasSize(1);
column = table.getColumns().get(0);
assertThat(column.getColumn()).isEqualTo("test_column");
assertThat(column.getMasks()).isEmpty();
}
use of io.trino.spi.eventlistener.TableInfo in project trino by trinodb.
the class TestEventListenerBasic method testReferencedTablesAndRoutines.
@Test
public void testReferencedTablesAndRoutines() throws Exception {
runQueryAndWaitForEvents("SELECT sum(linenumber) FROM lineitem", 2);
QueryCompletedEvent event = getOnlyElement(generatedEvents.getQueryCompletedEvents());
List<TableInfo> tables = event.getMetadata().getTables();
assertEquals(tables.size(), 1);
TableInfo table = tables.get(0);
assertEquals(table.getCatalog(), "tpch");
assertEquals(table.getSchema(), "tiny");
assertEquals(table.getTable(), "lineitem");
assertEquals(table.getAuthorization(), "user");
assertTrue(table.getFilters().isEmpty());
assertEquals(table.getColumns().size(), 1);
ColumnInfo column = table.getColumns().get(0);
assertEquals(column.getColumn(), "linenumber");
assertTrue(column.getMasks().isEmpty());
List<RoutineInfo> routines = event.getMetadata().getRoutines();
assertEquals(tables.size(), 1);
RoutineInfo routine = routines.get(0);
assertEquals(routine.getRoutine(), "sum");
assertEquals(routine.getAuthorization(), "user");
}
use of io.trino.spi.eventlistener.TableInfo in project trino by trinodb.
the class TestEventListenerBasic method testReferencedTablesInCreateView.
@Test
public void testReferencedTablesInCreateView() throws Exception {
runQueryAndWaitForEvents("CREATE VIEW mock.default.create_another_test_view AS SELECT * FROM nation", 2);
QueryCompletedEvent event = getOnlyElement(generatedEvents.getQueryCompletedEvents());
assertThat(event.getIoMetadata().getOutput().get().getCatalogName()).isEqualTo("mock");
assertThat(event.getIoMetadata().getOutput().get().getSchema()).isEqualTo("default");
assertThat(event.getIoMetadata().getOutput().get().getTable()).isEqualTo("create_another_test_view");
assertThat(event.getIoMetadata().getOutput().get().getColumns().get()).containsExactly(new OutputColumnMetadata("nationkey", BIGINT_TYPE, ImmutableSet.of(new ColumnDetail("tpch", "tiny", "nation", "nationkey"))), new OutputColumnMetadata("name", "varchar(25)", ImmutableSet.of(new ColumnDetail("tpch", "tiny", "nation", "name"))), new OutputColumnMetadata("regionkey", BIGINT_TYPE, ImmutableSet.of(new ColumnDetail("tpch", "tiny", "nation", "regionkey"))), new OutputColumnMetadata("comment", "varchar(152)", ImmutableSet.of(new ColumnDetail("tpch", "tiny", "nation", "comment"))));
List<TableInfo> tables = event.getMetadata().getTables();
assertThat(tables).hasSize(1);
TableInfo table = tables.get(0);
assertThat(table.getCatalog()).isEqualTo("tpch");
assertThat(table.getSchema()).isEqualTo("tiny");
assertThat(table.getTable()).isEqualTo("nation");
assertThat(table.getAuthorization()).isEqualTo("user");
assertThat(table.isDirectlyReferenced()).isTrue();
assertThat(table.getFilters()).isEmpty();
assertThat(table.getColumns()).hasSize(4);
}
Aggregations