@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(); } }
private Builder(Table tablePb) { super(tablePb); if (tablePb.getNumRows() != null) { this.numRows(tablePb.getNumRows().longValue()); } this.numBytes = tablePb.getNumBytes(); this.location = tablePb.getLocation(); if (tablePb.getStreamingBuffer() != null) { this.streamingBuffer = StreamingBuffer.fromPb(tablePb.getStreamingBuffer()); } if (tablePb.getTimePartitioning() != null) { this.timePartitioning = TimePartitioning.fromPb(tablePb.getTimePartitioning()); } }
@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(); } }
Table table = checkNotNull(datasetService.getTable(source)); if (!first) { if (!Objects.equals(partitioning, table.getTimePartitioning())) { return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto()); partitioning = table.getTimePartitioning(); schema = table.getSchema(); first = false;
public void testTimePartitioning(BigQueryIO.Write.Method insertMethod) throws Exception { TableRow row1 = new TableRow().set("name", "a").set("number", "1"); TableRow row2 = new TableRow().set("name", "b").set("number", "2"); TimePartitioning timePartitioning = new TimePartitioning().setType("DAY").setExpirationMs(1000L); TableSchema schema = new TableSchema() .setFields( ImmutableList.of(new TableFieldSchema().setName("number").setType("INTEGER"))); p.apply(Create.of(row1, row2)) .apply( BigQueryIO.writeTableRows() .to("project-id:dataset-id.table-id") .withTestServices(fakeBqServices) .withMethod(insertMethod) .withSchema(schema) .withTimePartitioning(timePartitioning) .withoutValidation()); p.run(); Table table = fakeDatasetService.getTable( BigQueryHelpers.parseTableSpec("project-id:dataset-id.table-id")); assertEquals(schema, table.getSchema()); assertEquals(timePartitioning, table.getTimePartitioning()); }