Skip to content

Commit 5f39b19

Browse files
feat: add remaining Statement Types (#3381)
* 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>
1 parent efa1aef commit 5f39b19

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobStatistics.java

+38
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,44 @@ public StatementType apply(String constant) {
452452
public static final StatementType DROP_FUNCTION = type.createAndRegister("DROP_FUNCTION");
453453
public static final StatementType DROP_PROCEDURE = type.createAndRegister("DROP_PROCEDURE");
454454
public static final StatementType MERGE = type.createAndRegister("MERGE");
455+
public static final StatementType CREATE_MATERIALIZED_VIEW =
456+
type.createAndRegister("CREATE_MATERIALIZED_VIEW");
457+
public static final StatementType CREATE_TABLE_FUNCTION =
458+
type.createAndRegister("CREATE_TABLE_FUNCTION");
459+
public static final StatementType CREATE_ROW_ACCESS_POLICY =
460+
type.createAndRegister("CREATE_ROW_ACCESS_POLICY");
461+
public static final StatementType CREATE_SCHEMA = type.createAndRegister("CREATE_SCHEMA");
462+
public static final StatementType CREATE_SNAPSHOT_TABLE =
463+
type.createAndRegister("CREATE_SNAPSHOT_TABLE");
464+
public static final StatementType CREATE_SEARCH_INDEX =
465+
type.createAndRegister("CREATE_SEARCH_INDEX");
466+
public static final StatementType DROP_EXTERNAL_TABLE =
467+
type.createAndRegister("DROP_EXTERNAL_TABLE");
468+
469+
public static final StatementType DROP_MODEL = type.createAndRegister("DROP_MODEL");
470+
public static final StatementType DROP_MATERIALIZED_VIEW =
471+
type.createAndRegister("DROP_MATERIALIZED_VIEW");
472+
473+
public static final StatementType DROP_TABLE_FUNCTION =
474+
type.createAndRegister("DROP_TABLE_FUNCTION");
475+
public static final StatementType DROP_SEARCH_INDEX =
476+
type.createAndRegister("DROP_SEARCH_INDEX");
477+
public static final StatementType DROP_SCHEMA = type.createAndRegister("DROP_SCHEMA");
478+
public static final StatementType DROP_SNAPSHOT_TABLE =
479+
type.createAndRegister("DROP_SNAPSHOT_TABLE");
480+
public static final StatementType DROP_ROW_ACCESS_POLICY =
481+
type.createAndRegister("DROP_ROW_ACCESS_POLICY");
482+
public static final StatementType ALTER_MATERIALIZED_VIEW =
483+
type.createAndRegister("ALTER_MATERIALIZED_VIEW");
484+
public static final StatementType ALTER_SCHEMA = type.createAndRegister("ALTER_SCHEMA");
485+
public static final StatementType SCRIPT = type.createAndRegister("SCRIPT");
486+
public static final StatementType TRUNCATE_TABLE = type.createAndRegister("TRUNCATE_TABLE");
487+
public static final StatementType CREATE_EXTERNAL_TABLE =
488+
type.createAndRegister("CREATE_EXTERNAL_TABLE");
489+
public static final StatementType EXPORT_DATA = type.createAndRegister("EXPORT_DATA");
490+
public static final StatementType EXPORT_MODEL = type.createAndRegister("EXPORT_MODEL");
491+
public static final StatementType LOAD_DATA = type.createAndRegister("LOAD_DATA");
492+
public static final StatementType CALL = type.createAndRegister("CALL");
455493

456494
private StatementType(String constant) {
457495
super(constant);

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -7033,4 +7033,25 @@ public void testLoadConfigurationFlexibleColumnName() throws InterruptedExceptio
70337033
bigquery.delete(v2TableId);
70347034
}
70357035
}
7036+
7037+
@Test
7038+
public void testStatementType() throws InterruptedException {
7039+
String tableName = "test_materialized_view_table_statemnt_type";
7040+
String createQuery =
7041+
String.format(
7042+
"CREATE MATERIALIZED VIEW %s.%s.%s "
7043+
+ "AS (SELECT MAX(TimestampField) AS TimestampField,StringField, MAX(BooleanField) AS BooleanField FROM %s.%s.%s GROUP BY StringField)",
7044+
PROJECT_ID, DATASET, tableName, PROJECT_ID, DATASET, TABLE_ID.getTable());
7045+
TableResult result = bigquery.query(QueryJobConfiguration.of(createQuery));
7046+
assertNotNull(result);
7047+
Job job = bigquery.getJob(result.getJobId());
7048+
JobStatistics.QueryStatistics stats = job.getStatistics();
7049+
assertEquals(StatementType.CREATE_MATERIALIZED_VIEW, stats.getStatementType());
7050+
7051+
// cleanup
7052+
Table remoteTable = bigquery.getTable(DATASET, tableName);
7053+
assertNotNull(remoteTable);
7054+
assertTrue(remoteTable.getDefinition() instanceof MaterializedViewDefinition);
7055+
assertTrue(remoteTable.delete());
7056+
}
70367057
}

0 commit comments

Comments
 (0)