Search in sources :

Example 6 with OutputColumnMetadata

use of io.trino.spi.eventlistener.OutputColumnMetadata in project trino by trinodb.

the class TestEventListenerBasic method testOutputColumnsForCreateTableAsSelectAll.

@Test
public void testOutputColumnsForCreateTableAsSelectAll() throws Exception {
    runQueryAndWaitForEvents("CREATE TABLE mock.default.create_new_table AS SELECT * FROM nation", 2);
    QueryCompletedEvent event = getOnlyElement(generatedEvents.getQueryCompletedEvents());
    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"))));
}
Also used : ColumnDetail(io.trino.spi.eventlistener.ColumnDetail) QueryCompletedEvent(io.trino.spi.eventlistener.QueryCompletedEvent) OutputColumnMetadata(io.trino.spi.eventlistener.OutputColumnMetadata) Test(org.testng.annotations.Test)

Example 7 with OutputColumnMetadata

use of io.trino.spi.eventlistener.OutputColumnMetadata in project trino by trinodb.

the class TestEventListenerBasic method testReferencedTablesWithColumnMask.

@Test
public void testReferencedTablesWithColumnMask() throws Exception {
    runQueryAndWaitForEvents("CREATE TABLE mock.default.create_table_with_referring_mask AS SELECT * FROM mock.default.test_table_with_column_mask", 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_table_with_referring_mask");
    assertThat(event.getIoMetadata().getOutput().get().getColumns().get()).containsExactly(new OutputColumnMetadata("test_varchar", VARCHAR_TYPE, ImmutableSet.of(new ColumnDetail("mock", "default", "test_table_with_column_mask", "test_varchar"))), new OutputColumnMetadata("test_bigint", BIGINT_TYPE, ImmutableSet.of(new ColumnDetail("mock", "default", "test_table_with_column_mask", "test_bigint"))));
    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("orders");
    assertThat(table.getAuthorization()).isEqualTo("user");
    assertThat(table.isDirectlyReferenced()).isFalse();
    assertThat(table.getFilters()).isEmpty();
    assertThat(table.getColumns()).hasSize(1);
    ColumnInfo column = table.getColumns().get(0);
    assertThat(column.getColumn()).isEqualTo("orderkey");
    assertThat(column.getMasks()).isEmpty();
    table = tables.get(1);
    assertThat(table.getCatalog()).isEqualTo("mock");
    assertThat(table.getSchema()).isEqualTo("default");
    assertThat(table.getTable()).isEqualTo("test_table_with_column_mask");
    assertThat(table.getAuthorization()).isEqualTo("user");
    assertThat(table.isDirectlyReferenced()).isTrue();
    assertThat(table.getFilters()).isEmpty();
    assertThat(table.getColumns()).hasSize(2);
    column = table.getColumns().get(0);
    assertThat(column.getColumn()).isEqualTo("test_varchar");
    assertThat(column.getMasks()).hasSize(1);
    column = table.getColumns().get(1);
    assertThat(column.getColumn()).isEqualTo("test_bigint");
    assertThat(column.getMasks()).isEmpty();
}
Also used : ColumnDetail(io.trino.spi.eventlistener.ColumnDetail) QueryCompletedEvent(io.trino.spi.eventlistener.QueryCompletedEvent) ColumnInfo(io.trino.spi.eventlistener.ColumnInfo) TableInfo(io.trino.spi.eventlistener.TableInfo) OutputColumnMetadata(io.trino.spi.eventlistener.OutputColumnMetadata) Test(org.testng.annotations.Test)

Example 8 with OutputColumnMetadata

use of io.trino.spi.eventlistener.OutputColumnMetadata in project trino by trinodb.

the class TestEventListenerBasic method testOutputColumnsForCreateTableAsSelectWithAliasedColumn.

@Test
public void testOutputColumnsForCreateTableAsSelectWithAliasedColumn() throws Exception {
    runQueryAndWaitForEvents("CREATE TABLE mock.default.create_new_table(aliased_bigint, aliased_varchar) AS SELECT nationkey AS keynation, concat(name, comment) FROM nation", 2);
    QueryCompletedEvent event = getOnlyElement(generatedEvents.getQueryCompletedEvents());
    assertThat(event.getIoMetadata().getOutput().get().getColumns().get()).containsExactly(new OutputColumnMetadata("aliased_bigint", BIGINT_TYPE, ImmutableSet.of(new ColumnDetail("tpch", "tiny", "nation", "nationkey"))), new OutputColumnMetadata("aliased_varchar", "varchar", ImmutableSet.of(new ColumnDetail("tpch", "tiny", "nation", "name"), new ColumnDetail("tpch", "tiny", "nation", "comment"))));
}
Also used : ColumnDetail(io.trino.spi.eventlistener.ColumnDetail) QueryCompletedEvent(io.trino.spi.eventlistener.QueryCompletedEvent) OutputColumnMetadata(io.trino.spi.eventlistener.OutputColumnMetadata) Test(org.testng.annotations.Test)

Example 9 with OutputColumnMetadata

use of io.trino.spi.eventlistener.OutputColumnMetadata in project trino by trinodb.

the class TestEventListenerBasic method testOutputColumnsForCreateTableAsSelectAllFromMaterializedView.

@Test
public void testOutputColumnsForCreateTableAsSelectAllFromMaterializedView() throws Exception {
    runQueryAndWaitForEvents("CREATE TABLE mock.default.create_new_table AS SELECT * FROM mock.default.test_materialized_view", 2);
    QueryCompletedEvent event = getOnlyElement(generatedEvents.getQueryCompletedEvents());
    assertThat(event.getIoMetadata().getOutput().get().getColumns().get()).containsExactly(new OutputColumnMetadata("test_column", BIGINT_TYPE, ImmutableSet.of(new ColumnDetail("mock", "default", "test_materialized_view", "test_column"))));
}
Also used : ColumnDetail(io.trino.spi.eventlistener.ColumnDetail) QueryCompletedEvent(io.trino.spi.eventlistener.QueryCompletedEvent) OutputColumnMetadata(io.trino.spi.eventlistener.OutputColumnMetadata) Test(org.testng.annotations.Test)

Example 10 with OutputColumnMetadata

use of io.trino.spi.eventlistener.OutputColumnMetadata in project trino by trinodb.

the class TestEventListenerBasic method testCreateTable.

@Test
public void testCreateTable() throws Exception {
    runQueryAndWaitForEvents("CREATE TABLE mock.default.create_simple_table (test_column BIGINT)", 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_simple_table");
    assertThat(event.getIoMetadata().getOutput().get().getColumns().get()).containsExactly(new OutputColumnMetadata("test_column", BIGINT_TYPE, ImmutableSet.of()));
}
Also used : QueryCompletedEvent(io.trino.spi.eventlistener.QueryCompletedEvent) OutputColumnMetadata(io.trino.spi.eventlistener.OutputColumnMetadata) Test(org.testng.annotations.Test)

Aggregations

OutputColumnMetadata (io.trino.spi.eventlistener.OutputColumnMetadata)14 QueryCompletedEvent (io.trino.spi.eventlistener.QueryCompletedEvent)13 Test (org.testng.annotations.Test)13 ColumnDetail (io.trino.spi.eventlistener.ColumnDetail)9 TableInfo (io.trino.spi.eventlistener.TableInfo)3 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 Input (io.trino.execution.Input)1 OperatorStats (io.trino.operator.OperatorStats)1 TableFinishInfo (io.trino.operator.TableFinishInfo)1 ColumnInfo (io.trino.spi.eventlistener.ColumnInfo)1 QueryIOMetadata (io.trino.spi.eventlistener.QueryIOMetadata)1 QueryInputMetadata (io.trino.spi.eventlistener.QueryInputMetadata)1 QueryOutputMetadata (io.trino.spi.eventlistener.QueryOutputMetadata)1 Analysis (io.trino.sql.analyzer.Analysis)1 List (java.util.List)1 OptionalLong (java.util.OptionalLong)1