Skip to content

Commit

Permalink
feat: add remaining Statement Types (#3381)
Browse files Browse the repository at this point in the history
* feat: add remaining Statement Types

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
Neenu1995 and gcf-owl-bot[bot] authored Jul 9, 2024
1 parent efa1aef commit 5f39b19
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,44 @@ public StatementType apply(String constant) {
public static final StatementType DROP_FUNCTION = type.createAndRegister("DROP_FUNCTION");
public static final StatementType DROP_PROCEDURE = type.createAndRegister("DROP_PROCEDURE");
public static final StatementType MERGE = type.createAndRegister("MERGE");
public static final StatementType CREATE_MATERIALIZED_VIEW =
type.createAndRegister("CREATE_MATERIALIZED_VIEW");
public static final StatementType CREATE_TABLE_FUNCTION =
type.createAndRegister("CREATE_TABLE_FUNCTION");
public static final StatementType CREATE_ROW_ACCESS_POLICY =
type.createAndRegister("CREATE_ROW_ACCESS_POLICY");
public static final StatementType CREATE_SCHEMA = type.createAndRegister("CREATE_SCHEMA");
public static final StatementType CREATE_SNAPSHOT_TABLE =
type.createAndRegister("CREATE_SNAPSHOT_TABLE");
public static final StatementType CREATE_SEARCH_INDEX =
type.createAndRegister("CREATE_SEARCH_INDEX");
public static final StatementType DROP_EXTERNAL_TABLE =
type.createAndRegister("DROP_EXTERNAL_TABLE");

public static final StatementType DROP_MODEL = type.createAndRegister("DROP_MODEL");
public static final StatementType DROP_MATERIALIZED_VIEW =
type.createAndRegister("DROP_MATERIALIZED_VIEW");

public static final StatementType DROP_TABLE_FUNCTION =
type.createAndRegister("DROP_TABLE_FUNCTION");
public static final StatementType DROP_SEARCH_INDEX =
type.createAndRegister("DROP_SEARCH_INDEX");
public static final StatementType DROP_SCHEMA = type.createAndRegister("DROP_SCHEMA");
public static final StatementType DROP_SNAPSHOT_TABLE =
type.createAndRegister("DROP_SNAPSHOT_TABLE");
public static final StatementType DROP_ROW_ACCESS_POLICY =
type.createAndRegister("DROP_ROW_ACCESS_POLICY");
public static final StatementType ALTER_MATERIALIZED_VIEW =
type.createAndRegister("ALTER_MATERIALIZED_VIEW");
public static final StatementType ALTER_SCHEMA = type.createAndRegister("ALTER_SCHEMA");
public static final StatementType SCRIPT = type.createAndRegister("SCRIPT");
public static final StatementType TRUNCATE_TABLE = type.createAndRegister("TRUNCATE_TABLE");
public static final StatementType CREATE_EXTERNAL_TABLE =
type.createAndRegister("CREATE_EXTERNAL_TABLE");
public static final StatementType EXPORT_DATA = type.createAndRegister("EXPORT_DATA");
public static final StatementType EXPORT_MODEL = type.createAndRegister("EXPORT_MODEL");
public static final StatementType LOAD_DATA = type.createAndRegister("LOAD_DATA");
public static final StatementType CALL = type.createAndRegister("CALL");

private StatementType(String constant) {
super(constant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7033,4 +7033,25 @@ public void testLoadConfigurationFlexibleColumnName() throws InterruptedExceptio
bigquery.delete(v2TableId);
}
}

@Test
public void testStatementType() throws InterruptedException {
String tableName = "test_materialized_view_table_statemnt_type";
String createQuery =
String.format(
"CREATE MATERIALIZED VIEW %s.%s.%s "
+ "AS (SELECT MAX(TimestampField) AS TimestampField,StringField, MAX(BooleanField) AS BooleanField FROM %s.%s.%s GROUP BY StringField)",
PROJECT_ID, DATASET, tableName, PROJECT_ID, DATASET, TABLE_ID.getTable());
TableResult result = bigquery.query(QueryJobConfiguration.of(createQuery));
assertNotNull(result);
Job job = bigquery.getJob(result.getJobId());
JobStatistics.QueryStatistics stats = job.getStatistics();
assertEquals(StatementType.CREATE_MATERIALIZED_VIEW, stats.getStatementType());

// cleanup
Table remoteTable = bigquery.getTable(DATASET, tableName);
assertNotNull(remoteTable);
assertTrue(remoteTable.getDefinition() instanceof MaterializedViewDefinition);
assertTrue(remoteTable.delete());
}
}

0 comments on commit 5f39b19

Please sign in to comment.