Skip to content

Commit

Permalink
Add test for aggregating BigQuery view more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Jan 25, 2021
1 parent 54beed2 commit 152abe9
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.testing.MaterializedResult.resultBuilder;
import static io.trino.testing.assertions.Assert.assertEquals;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -133,6 +134,25 @@ public void testCountAggregationView()
"VALUES (1)");
}

/**
* regression test for https://github.com/trinodb/trino/issues/6696
*/
@Test
public void testRepeatCountAggregationView()
{
BigQuery client = createBigQueryClient();

String viewName = "test.repeat_count_aggregation_view_" + randomTableSuffix();

executeBigQuerySql(client, "DROP VIEW IF EXISTS " + viewName);
executeBigQuerySql(client, "CREATE VIEW " + viewName + " AS SELECT 1 AS col1");

assertQuery("SELECT count(*) FROM " + viewName, "VALUES (1)");
assertQuery("SELECT count(*) FROM " + viewName, "VALUES (1)");

executeBigQuerySql(client, "DROP VIEW " + viewName);
}

private static void executeBigQuerySql(BigQuery bigquery, String query)
{
QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query)
Expand Down

0 comments on commit 152abe9

Please sign in to comment.