Interface BigQueryOperations
- All Known Implementing Classes:
BigQueryTemplate
public interface BigQueryOperations
Defines operations for use with BigQuery.
- Since:
- 1.2
-
Method Summary
Modifier and TypeMethodDescriptionCompletableFuture<com.google.cloud.bigquery.Job>
writeDataToTable
(String tableName, InputStream inputStream, com.google.cloud.bigquery.FormatOptions dataFormatOptions) Writes data to a specified BigQuery table.CompletableFuture<com.google.cloud.bigquery.Job>
writeDataToTable
(String tableName, InputStream inputStream, com.google.cloud.bigquery.FormatOptions dataFormatOptions, com.google.cloud.bigquery.Schema schema) Writes data to a specified BigQuery table with a manually-specified table Schema.writeJsonStream
(String tableName, InputStream jsonInputStream) This method uses BigQuery Storage Write API to write new line delimited JSON file to the specified table.writeJsonStream
(String tableName, InputStream jsonInputStream, com.google.cloud.bigquery.Schema schema) This method uses BigQuery Storage Write API to write new line delimited JSON file to the specified table.
-
Method Details
-
writeDataToTable
CompletableFuture<com.google.cloud.bigquery.Job> writeDataToTable(String tableName, InputStream inputStream, com.google.cloud.bigquery.FormatOptions dataFormatOptions) Writes data to a specified BigQuery table.- Parameters:
tableName
- name of the table to write toinputStream
- input stream of the table data to writedataFormatOptions
- the format of the data to write- Returns:
CompletableFuture
containing the BigQuery Job indicating completion of operation- Throws:
BigQueryException
- if errors occur when loading data to the BigQuery table
-
writeDataToTable
CompletableFuture<com.google.cloud.bigquery.Job> writeDataToTable(String tableName, InputStream inputStream, com.google.cloud.bigquery.FormatOptions dataFormatOptions, com.google.cloud.bigquery.Schema schema) Writes data to a specified BigQuery table with a manually-specified table Schema.Example:
Schema schema = Schema.of( Field.of("CountyId", StandardSQLTypeName.INT64), Field.of("State", StandardSQLTypeName.STRING), Field.of("County", StandardSQLTypeName.STRING) ); CompletableFuture<Job> bigQueryJobFuture = bigQueryTemplate.writeDataToTable( TABLE_NAME, dataFile.getInputStream(), FormatOptions.csv(), schema);
- Parameters:
tableName
- name of the table to write toinputStream
- input stream of the table data to writedataFormatOptions
- the format of the data to writeschema
- the schema of the table being loaded- Returns:
CompletableFuture
containing the BigQuery Job indicating completion of operation- Throws:
BigQueryException
- if errors occur when loading data to the BigQuery table
-
writeJsonStream
This method uses BigQuery Storage Write API to write new line delimited JSON file to the specified table. The Table should already be created as BigQuery Storage Write API doesn't create it automatically.- Parameters:
tableName
- name of the table to write tojsonInputStream
- input stream of the json file to be written- Returns:
CompletableFuture
containing the WriteApiResponse indicating completion of operation
-
writeJsonStream
CompletableFuture<WriteApiResponse> writeJsonStream(String tableName, InputStream jsonInputStream, com.google.cloud.bigquery.Schema schema) This method uses BigQuery Storage Write API to write new line delimited JSON file to the specified table. This method creates a table with the specified schema.- Parameters:
tableName
- name of the table to write tojsonInputStream
- input stream of the json file to be written- Returns:
CompletableFuture
containing the WriteApiResponse indicating completion of operation
-