Tabnine Logo
TableInfo$Builder
Code IndexAdd Tabnine to your IDE (free)

How to use
TableInfo$Builder
in
com.google.cloud.bigquery

Best Java code snippets using com.google.cloud.bigquery.TableInfo$Builder (Showing top 20 results out of 315)

origin: googleapis/google-cloud-java

Schema schema = Schema.of(Field.of("name", LegacySQLTypeName.STRING));
TableDefinition tableDef = StandardTableDefinition.of(schema);
Table table = bigquery.create(TableInfo.newBuilder(tableId, tableDef).build());
origin: googleapis/google-cloud-java

@Test
public void testUpdateTable() {
 String tableName = "test_update_table";
 StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
 TableInfo tableInfo =
   TableInfo.newBuilder(TableId.of(DATASET, tableName), tableDefinition)
     .setDescription("Some Description")
     .setLabels(Collections.singletonMap("a", "b"))
     .build();
 Table createdTable = bigquery.create(tableInfo);
 assertThat(createdTable.getDescription()).isEqualTo("Some Description");
 assertThat(createdTable.getLabels()).containsExactly("a", "b");
 Map<String, String> updateLabels = new HashMap<>();
 updateLabels.put("x", "y");
 updateLabels.put("a", null);
 Table updatedTable =
   bigquery.update(
     createdTable
       .toBuilder()
       .setDescription("Updated Description")
       .setLabels(updateLabels)
       .build());
 assertThat(updatedTable.getDescription()).isEqualTo("Updated Description");
 assertThat(updatedTable.getLabels()).containsExactly("x", "y");
 updatedTable = bigquery.update(updatedTable.toBuilder().setLabels(null).build());
 assertThat(updatedTable.getLabels()).isEmpty();
 assertThat(createdTable.delete()).isTrue();
}
origin: googleapis/google-cloud-java

@Test
public void testUpdateTableWithoutProject() {
 TableInfo tableInfo = TABLE_INFO.setProjectId(PROJECT);
 TableId tableId = TableId.of("", TABLE_ID.getDataset(), TABLE_ID.getTable());
 tableInfo.toBuilder().setTableId(tableId);
 EasyMock.expect(bigqueryRpcMock.patch(tableInfo.toPb(), EMPTY_RPC_OPTIONS))
   .andReturn(tableInfo.toPb());
 EasyMock.replay(bigqueryRpcMock);
 BigQueryOptions bigQueryOptions = createBigQueryOptionsForProject(PROJECT, rpcFactoryMock);
 bigquery = bigQueryOptions.getService();
 Table table = bigquery.update(tableInfo);
 assertEquals(new Table(bigquery, new TableInfo.BuilderImpl(tableInfo)), table);
}
origin: gojek/feast

     .setTimePartitioning(TimePartitioning.of(Type.DAY))
     .build();
 TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();
 checkTableCreation(bigQuery.create(tableInfo), featureSpec);
Schema newSchema = Schema.of(fields);
TableDefinition tableDefinition = StandardTableDefinition.of(newSchema);
TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();
checkTableCreation(bigQuery.update(tableInfo), featureSpec);
createOrUpdateView(
origin: wepay/kafka-connect-bigquery

 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();
 }
}
origin: com.google.cloud/gcloud-java-bigquery

TableInfo setProjectId(String projectId) {
 return toBuilder().tableId(tableId().setProjectId(projectId)).build();
}
origin: com.google.cloud/google-cloud-bigquery

/**
 * Returns a builder for a {@code TableInfo} object given table identity and definition. Use
 * {@link StandardTableDefinition} to create simple BigQuery table. Use {@link ViewDefinition} to
 * create a BigQuery view. Use {@link ExternalTableDefinition} to create a BigQuery a table backed
 * by external data.
 */
public static Builder newBuilder(TableId tableId, TableDefinition definition) {
 return new BuilderImpl().setTableId(tableId).setDefinition(definition);
}
origin: com.google.cloud/google-cloud-bigquery

/**
 * Returns a {@code TableInfo} object given table identity and definition. Use {@link
 * StandardTableDefinition} to create simple BigQuery table. Use {@link ViewDefinition} to create
 * a BigQuery view. Use {@link ExternalTableDefinition} to create a BigQuery a table backed by
 * external data.
 */
public static TableInfo of(TableId tableId, TableDefinition definition) {
 return newBuilder(tableId, definition).build();
}
origin: com.google.cloud/gcloud-java-bigquery

/**
 * Returns a {@code TableInfo} object given table identity and definition. Use
 * {@link StandardTableDefinition} to create simple BigQuery table. Use {@link ViewDefinition} to
 * create a BigQuery view. Use {@link ExternalTableDefinition} to create a BigQuery a table backed
 * by external data.
 */
public static TableInfo of(TableId tableId, TableDefinition definition) {
 return builder(tableId, definition).build();
}
origin: io.konig/konig-gcp-common

public static TableInfo createTableInfo(com.google.api.services.bigquery.model.Table model) {
  String type = model.getType();
  if (type == null) {
    model.setType(TableDefinition.Type.TABLE.name());
  }
  TableId tableId = TableId.fromPb(model.getTableReference());
  TableDefinition definition = tableDefinition(model);
  return TableInfo.newBuilder(tableId, definition).build();
}

origin: com.google.cloud/gcloud-java-bigquery

Builder(BigQuery bigquery, TableId tableId, TableDefinition defintion) {
 this.bigquery = bigquery;
 this.infoBuilder = new TableInfo.BuilderImpl();
 this.infoBuilder.tableId(tableId).definition(defintion);
}
origin: org.apache.beam/beam-sdks-java-test-utils

private void createTable(TableId tableId, Schema schema) {
 TableInfo tableInfo =
   TableInfo.newBuilder(tableId, StandardTableDefinition.of(schema))
     .setFriendlyName(tableId.getTable())
     .build();
 client.create(tableInfo, FIELD_OPTIONS);
}
origin: com.google.cloud/gcloud-java-bigquery

/**
 * Returns a builder for a {@code TableInfo} object given table identity and definition. Use
 * {@link StandardTableDefinition} to create simple BigQuery table. Use {@link ViewDefinition} to
 * create a BigQuery view. Use {@link ExternalTableDefinition} to create a BigQuery a table backed
 * by external data.
 */
public static Builder builder(TableId tableId, TableDefinition definition) {
 return new BuilderImpl().tableId(tableId).definition(definition);
}
origin: com.google.cloud/google-cloud-bigquery

Builder(BigQuery bigquery, TableId tableId, TableDefinition defintion) {
 this.bigquery = bigquery;
 this.infoBuilder = new TableInfo.BuilderImpl();
 this.infoBuilder.setTableId(tableId).setDefinition(defintion);
}
origin: com.google.cloud/google-cloud-bigquery

TableInfo setProjectId(String projectId) {
 if (Strings.isNullOrEmpty(getTableId().getProject())) {
  return toBuilder().setTableId(getTableId().setProjectId(projectId)).build();
 }
 return this;
}
origin: googleapis/google-cloud-java

@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());
}
origin: googleapis/google-cloud-java

@Test
public void testUpdateTableWithSelectedFields() {
 Capture<Map<BigQueryRpc.Option, Object>> capturedOptions = Capture.newInstance();
 TableInfo updatedTableInfo = TABLE_INFO.toBuilder().setDescription("newDescription").build();
 TableInfo updatedTableInfoWithProject =
   TABLE_INFO_WITH_PROJECT.toBuilder().setDescription("newDescription").build();
 EasyMock.expect(
     bigqueryRpcMock.patch(eq(updatedTableInfoWithProject.toPb()), capture(capturedOptions)))
   .andReturn(updatedTableInfoWithProject.toPb());
 EasyMock.replay(bigqueryRpcMock);
 bigquery = options.getService();
 Table table = bigquery.update(updatedTableInfo, TABLE_OPTION_FIELDS);
 String selector = (String) capturedOptions.getValue().get(TABLE_OPTION_FIELDS.getRpcOption());
 assertTrue(selector.contains("tableReference"));
 assertTrue(selector.contains("schema"));
 assertTrue(selector.contains("etag"));
 assertEquals(31, selector.length());
 assertEquals(
   new Table(bigquery, new TableInfo.BuilderImpl(updatedTableInfoWithProject)), table);
}
origin: googleapis/google-cloud-java

@Test
public void testUpdateTableWithSelectedFields() {
 String tableName = "test_update_with_selected_fields_table";
 StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
 TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
 Table createdTable = bigquery.create(tableInfo);
 assertNotNull(createdTable);
 Table updatedTable =
   bigquery.update(
     tableInfo.toBuilder().setDescription("newDescr").build(),
     TableOption.fields(TableField.DESCRIPTION));
 assertTrue(updatedTable.getDefinition() instanceof StandardTableDefinition);
 assertEquals(DATASET, updatedTable.getTableId().getDataset());
 assertEquals(tableName, updatedTable.getTableId().getTable());
 assertEquals("newDescr", updatedTable.getDescription());
 assertNull(updatedTable.getDefinition().getSchema());
 assertNull(updatedTable.getLastModifiedTime());
 assertNull(updatedTable.<StandardTableDefinition>getDefinition().getNumBytes());
 assertNull(updatedTable.<StandardTableDefinition>getDefinition().getNumRows());
 assertTrue(createdTable.delete());
}
origin: googleapis/google-cloud-java

/** Example of creating a table. */
// [TARGET create(TableInfo, TableOption...)]
// [VARIABLE "my_dataset_name"]
// [VARIABLE "my_table_name"]
// [VARIABLE "string_field"]
public Table createTable(String datasetName, String tableName, String fieldName) {
 // [START bigquery_create_table]
 TableId tableId = TableId.of(datasetName, tableName);
 // Table field definition
 Field field = Field.of(fieldName, LegacySQLTypeName.STRING);
 // Table schema definition
 Schema schema = Schema.of(field);
 TableDefinition tableDefinition = StandardTableDefinition.of(schema);
 TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();
 Table table = bigquery.create(tableInfo);
 // [END bigquery_create_table]
 return table;
}
origin: googleapis/google-cloud-java

@Test
public void testReload() throws Exception {
 initializeExpectedTable(4);
 TableInfo updatedInfo = TABLE_INFO.toBuilder().setDescription("Description").build();
 Table expectedTable =
   new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(updatedInfo));
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.getTable(TABLE_INFO.getTableId())).andReturn(expectedTable);
 replay(bigquery);
 initializeTable();
 Table updatedTable = table.reload();
 compareTable(expectedTable, updatedTable);
}
com.google.cloud.bigqueryTableInfo$Builder

Javadoc

A builder for TableInfo objects.

Most used methods

  • build
    Creates a TableInfo object.
  • setDescription
    Sets a user-friendly description for the table.
  • setTableId
    Sets the table identity.
  • definition
    Sets the table definition. Use StandardTableDefinition to create simple BigQuery table. Use ViewDefi
  • setDefinition
    Sets the table definition. Use StandardTableDefinition to create simple BigQuery table. Use ViewDefi
  • setFriendlyName
    Sets a user-friendly name for the table.
  • setLabels
    Sets the labels applied to this table.Unstable, because labels are experimental [https://cloud.googl
  • tableId
    Sets the table identity.

Popular in Java

  • Making http post requests using okhttp
  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now