@Override Table toPb() { Table tablePb = super.toPb(); if (getNumRows() != null) { tablePb.setNumRows(BigInteger.valueOf(getNumRows())); } tablePb.setNumBytes(getNumBytes()); tablePb.setLocation(getLocation()); if (getStreamingBuffer() != null) { tablePb.setStreamingBuffer(getStreamingBuffer().toPb()); } if (getTimePartitioning() != null) { tablePb.setTimePartitioning(getTimePartitioning().toPb()); } if (getClustering() != null) { tablePb.setClustering(getClustering().toPb()); } return tablePb; }
private void compareStandardTableDefinition( StandardTableDefinition expected, StandardTableDefinition value) { assertEquals(expected, value); assertEquals(expected.getSchema(), value.getSchema()); assertEquals(expected.getType(), value.getType()); assertEquals(expected.getNumBytes(), value.getNumBytes()); assertEquals(expected.getNumRows(), value.getNumRows()); assertEquals(expected.getLocation(), value.getLocation()); assertEquals(expected.getStreamingBuffer(), value.getStreamingBuffer()); assertEquals(expected.getType(), value.getType()); assertEquals(expected.getTimePartitioning(), value.getTimePartitioning()); assertEquals(expected.getClustering(), value.getClustering()); assertEquals(expected.hashCode(), value.hashCode()); } }
assertThat( ((StandardTableDefinition) table.getDefinition()) .getTimePartitioning() .getExpirationMs()) .isNull(); assertThat( ((StandardTableDefinition) table.getDefinition()) .getTimePartitioning() .getExpirationMs()) .isEqualTo(42L); assertThat( ((StandardTableDefinition) table.getDefinition()) .getTimePartitioning() .getExpirationMs()) .isNull();
@Test public void testBuilder() { assertEquals(TableDefinition.Type.TABLE, TABLE_DEFINITION.getType()); assertEquals(TABLE_SCHEMA, TABLE_DEFINITION.getSchema()); assertEquals(LOCATION, TABLE_DEFINITION.getLocation()); assertEquals(NUM_BYTES, TABLE_DEFINITION.getNumBytes()); assertEquals(NUM_ROWS, TABLE_DEFINITION.getNumRows()); assertEquals(STREAMING_BUFFER, TABLE_DEFINITION.getStreamingBuffer()); assertEquals(TIME_PARTITIONING, TABLE_DEFINITION.getTimePartitioning()); assertEquals(CLUSTERING, TABLE_DEFINITION.getClustering()); }
@Test public void testOf() { StandardTableDefinition definition = StandardTableDefinition.of(TABLE_SCHEMA); assertEquals(TableDefinition.Type.TABLE, TABLE_DEFINITION.getType()); assertEquals(TABLE_SCHEMA, TABLE_DEFINITION.getSchema()); assertNull(definition.getLocation()); assertNull(definition.getNumBytes()); assertNull(definition.getNumRows()); assertNull(definition.getStreamingBuffer()); assertNull(definition.getTimePartitioning()); assertNull(definition.getClustering()); }
@Test public void testCreateAndGetTableWithSelectedField() { String tableName = "test_create_and_get_selected_fields_table"; TableId tableId = TableId.of(DATASET, tableName); StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA); Table createdTable = bigquery.create( TableInfo.newBuilder(tableId, tableDefinition) .setLabels(Collections.singletonMap("a", "b")) .build()); assertNotNull(createdTable); assertEquals(DATASET, createdTable.getTableId().getDataset()); assertEquals(tableName, createdTable.getTableId().getTable()); Table remoteTable = bigquery.getTable( DATASET, tableName, TableOption.fields(TableField.CREATION_TIME, TableField.LABELS)); assertNotNull(remoteTable); assertTrue(remoteTable.getDefinition() instanceof StandardTableDefinition); assertEquals(createdTable.getTableId(), remoteTable.getTableId()); assertEquals(TableDefinition.Type.TABLE, remoteTable.getDefinition().getType()); assertThat(remoteTable.getLabels()).containsExactly("a", "b"); assertNotNull(remoteTable.getCreationTime()); assertNull(remoteTable.getDefinition().getSchema()); assertNull(remoteTable.getLastModifiedTime()); assertNull(remoteTable.<StandardTableDefinition>getDefinition().getNumBytes()); assertNull(remoteTable.<StandardTableDefinition>getDefinition().getNumRows()); assertNull(remoteTable.<StandardTableDefinition>getDefinition().getTimePartitioning()); assertNull(remoteTable.<StandardTableDefinition>getDefinition().getClustering()); assertTrue(remoteTable.delete()); }
assertNotNull(remoteTable.<StandardTableDefinition>getDefinition().getNumRows()); assertEquals( partitioning, remoteTable.<StandardTableDefinition>getDefinition().getTimePartitioning()); assertEquals(clustering, remoteTable.<StandardTableDefinition>getDefinition().getClustering()); assertTrue(remoteTable.delete());
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof StandardTableDefinition) { StandardTableDefinition that = (StandardTableDefinition) o; return (this.type.equals(that.getType())) && ((this.schema == null) ? (that.getSchema() == null) : this.schema.equals(that.getSchema())) && ((this.numBytes == null) ? (that.getNumBytes() == null) : this.numBytes.equals(that.getNumBytes())) && ((this.numRows == null) ? (that.getNumRows() == null) : this.numRows.equals(that.getNumRows())) && ((this.location == null) ? (that.getLocation() == null) : this.location.equals(that.getLocation())) && ((this.streamingBuffer == null) ? (that.getStreamingBuffer() == null) : this.streamingBuffer.equals(that.getStreamingBuffer())) && ((this.timePartitioning == null) ? (that.getTimePartitioning() == null) : this.timePartitioning.equals(that.getTimePartitioning())) && ((this.clustering == null) ? (that.getClustering() == null) : this.clustering.equals(that.getClustering())); } return false; }
private Builder(StandardTableDefinition source) { this.type = source.getType(); this.schema = source.getSchema(); this.numBytes = source.getNumBytes(); this.numRows = source.getNumRows(); this.location = source.getLocation(); this.streamingBuffer = source.getStreamingBuffer(); this.timePartitioning = source.getTimePartitioning(); this.clustering = source.getClustering(); } @Override
@Override Table toPb() { Table tablePb = super.toPb(); if (getNumRows() != null) { tablePb.setNumRows(BigInteger.valueOf(getNumRows())); } tablePb.setNumBytes(getNumBytes()); tablePb.setLocation(getLocation()); if (getStreamingBuffer() != null) { tablePb.setStreamingBuffer(getStreamingBuffer().toPb()); } if (getTimePartitioning() != null) { tablePb.setTimePartitioning(getTimePartitioning().toPb()); } if (getClustering() != null) { tablePb.setClustering(getClustering().toPb()); } return tablePb; }