@Test public void testTypeOf_Npe() { thrown.expect(NullPointerException.class); TimePartitioning.of(null); }
@Test public void testTypeAndExpirationOf_Npe() { thrown.expect(NullPointerException.class); TimePartitioning.of(null, EXPIRATION_MS); }
/** Example of creating a table in the dataset with schema and time partitioning. */ // [TARGET create(String, TableDefinition, TableOption...)] // [VARIABLE “my_table”] // [VARIABLE “my_field”] public Table createTable(String tableName, String fieldName) { // [START ] Schema schema = Schema.of(Field.of(fieldName, LegacySQLTypeName.STRING)); StandardTableDefinition definition = StandardTableDefinition.newBuilder() .setSchema(schema) .setTimePartitioning(TimePartitioning.of(TimePartitioning.Type.DAY)) .build(); Table table = dataset.create(tableName, definition); // [END ] return table; } }
@Test public void testToAndFromPb() { compareTimePartitioning(TIME_PARTITIONING, TimePartitioning.fromPb(TIME_PARTITIONING.toPb())); TimePartitioning partitioning = TimePartitioning.of(TYPE); compareTimePartitioning(partitioning, TimePartitioning.fromPb(partitioning.toPb())); }
@Test public void testOf() { assertEquals(TYPE, TIME_PARTITIONING.getType()); assertEquals(EXPIRATION_MS, TIME_PARTITIONING.getExpirationMs().longValue()); assertEquals(REQUIRE_PARTITION_FILTER, TIME_PARTITIONING.getRequirePartitionFilter()); assertEquals(FIELD, TIME_PARTITIONING.getField()); TimePartitioning partitioning = TimePartitioning.of(TYPE); assertEquals(TYPE, partitioning.getType()); assertNull(partitioning.getExpirationMs()); }
StandardTableDefinition.newBuilder() .setSchema(TABLE_SCHEMA) .setTimePartitioning(TimePartitioning.of(Type.DAY)) .build(); tableDefinition .toBuilder() .setTimePartitioning(TimePartitioning.of(Type.DAY, 42L)) .build()) .build() tableDefinition .toBuilder() .setTimePartitioning(TimePartitioning.of(Type.DAY)) .build()) .build()
String tableName = "test_create_and_get_table"; TableId tableId = TableId.of(DATASET, tableName); TimePartitioning partitioning = TimePartitioning.of(Type.DAY); Clustering clustering = Clustering.newBuilder().setFields(ImmutableList.of(STRING_FIELD_SCHEMA.getName())).build();
TableInfo constructTableInfo(TableId table, Schema kafkaConnectSchema) { com.google.cloud.bigquery.Schema bigQuerySchema = schemaConverter.convertSchema(kafkaConnectSchema); StandardTableDefinition tableDefinition = StandardTableDefinition.newBuilder() .setSchema(bigQuerySchema) .setTimePartitioning(TimePartitioning.of(TimePartitioning.Type.DAY)) .build(); TableInfo.Builder tableInfoBuilder = TableInfo.newBuilder(table, tableDefinition); if (kafkaConnectSchema.doc() != null) { tableInfoBuilder.setDescription(kafkaConnectSchema.doc()); } return tableInfoBuilder.build(); } }
StandardTableDefinition.newBuilder() .setSchema(schema) .setTimePartitioning(TimePartitioning.of(Type.DAY)) .build(); TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();