/** * Creates a BigQuery standard table definition given its schema. * * @param schema the schema of the table */ public static StandardTableDefinition of(Schema schema) { return newBuilder().setSchema(schema).build(); }
/** 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; } }
@SuppressWarnings("unchecked") static StandardTableDefinition fromPb(Table tablePb) { Builder builder = newBuilder().table(tablePb); if (tablePb.getNumRows() != null) { builder.setNumRows(tablePb.getNumRows().longValue()); } if (tablePb.getStreamingBuffer() != null) { builder.setStreamingBuffer(StreamingBuffer.fromPb(tablePb.getStreamingBuffer())); } if (tablePb.getTimePartitioning() != null) { builder.setTimePartitioning(TimePartitioning.fromPb(tablePb.getTimePartitioning())); } if (tablePb.getClustering() != null) { builder.setClustering(Clustering.fromPb(tablePb.getClustering())); } return builder.setNumBytes(tablePb.getNumBytes()).setLocation(tablePb.getLocation()).build(); } }
TableId tableId = TableId.of(DATASET, tableName); StandardTableDefinition tableDefinition = StandardTableDefinition.newBuilder() .setSchema(TABLE_SCHEMA) .setTimePartitioning(TimePartitioning.of(Type.DAY))
Clustering.newBuilder().setFields(ImmutableList.of(STRING_FIELD_SCHEMA.getName())).build(); StandardTableDefinition tableDefinition = StandardTableDefinition.newBuilder() .setSchema(TABLE_SCHEMA) .setTimePartitioning(partitioning)
/** * Creates a BigQuery standard table definition given its schema. * * @param schema the schema of the table */ public static StandardTableDefinition of(Schema schema) { return newBuilder().setSchema(schema).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(); } }
createFeatureField(featureSpec)); TableDefinition tableDefinition = StandardTableDefinition.newBuilder() .setSchema(schema) .setTimePartitioning(TimePartitioning.of(Type.DAY))
@SuppressWarnings("unchecked") static StandardTableDefinition fromPb(Table tablePb) { Builder builder = newBuilder().table(tablePb); if (tablePb.getNumRows() != null) { builder.setNumRows(tablePb.getNumRows().longValue()); } if (tablePb.getStreamingBuffer() != null) { builder.setStreamingBuffer(StreamingBuffer.fromPb(tablePb.getStreamingBuffer())); } if (tablePb.getTimePartitioning() != null) { builder.setTimePartitioning(TimePartitioning.fromPb(tablePb.getTimePartitioning())); } if (tablePb.getClustering() != null) { builder.setClustering(Clustering.fromPb(tablePb.getClustering())); } return builder.setNumBytes(tablePb.getNumBytes()).setLocation(tablePb.getLocation()).build(); } }