0
可以使用google-cloud-java SDK将列添加到现有表中吗?可以使用google-cloud-java SDK将列添加到现有表中
BigQuery的接口确实有update方法,但它似乎只能表的元数据
可以使用google-cloud-java SDK将列添加到现有表中吗?可以使用google-cloud-java SDK将列添加到现有表中
BigQuery的接口确实有update方法,但它似乎只能表的元数据
是啊,它肯定是。使用update
方法并提供新的模式。您需要提供整个模式,即旧的和新的列。 null
将插入新的列值。
这个例子将增加column_2
到已经有column_1
现有的表:
String datasetName = "test";
String tableName = "foo";
Table oldTable = bigQuery.getTable(datasetName, tableName);
Field col1 = Field.of("column_1", Field.Type.string());
Field col2 = Field.of("column_2", Field.Type.string());
Schema schema = Schema.of(col1, col2);
TableInfo tableInfo = oldTable.toBuilder().setDefinition(StandardTableDefinition.of(schema)).build();
bigQuery.update(tableInfo);