public class BigQueryClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
BigQueryClient.CreateTableOptions |
static interface |
BigQueryClient.LoadDataOptions |
static interface |
BigQueryClient.ReadTableOptions |
| Constructor and Description |
|---|
BigQueryClient(com.google.cloud.bigquery.BigQuery bigQuery,
Optional<String> materializationProject,
Optional<String> materializationDataset,
com.google.common.cache.Cache<String,com.google.cloud.bigquery.TableInfo> destinationTableCache,
Map<String,String> labels,
com.google.cloud.bigquery.QueryJobConfiguration.Priority queryJobPriority,
Optional<BigQueryJobCompletionListener> jobCompletionListener,
long bigQueryJobTimeoutInMinutes) |
| Modifier and Type | Method and Description |
|---|---|
com.google.cloud.bigquery.Job |
appendDestinationWithTemporary(com.google.cloud.bigquery.TableId temporaryTableId,
com.google.cloud.bigquery.TableId destinationTableId)
Appends all the data from the given temporary table, to the given destination table,
transactionally.
|
long |
calculateTableSize(com.google.cloud.bigquery.TableId tableId,
Optional<String> filter) |
long |
calculateTableSize(com.google.cloud.bigquery.TableInfo tableInfo,
Optional<String> filter) |
com.google.cloud.bigquery.Job |
createAndWaitFor(com.google.cloud.bigquery.JobConfiguration.Builder jobConfiguration) |
com.google.cloud.bigquery.Job |
createAndWaitFor(com.google.cloud.bigquery.JobConfiguration jobConfiguration) |
com.google.cloud.bigquery.TableInfo |
createTable(com.google.cloud.bigquery.TableId tableId,
com.google.cloud.bigquery.Schema schema,
BigQueryClient.CreateTableOptions options)
Creates an empty table in BigQuery.
|
void |
createTableIfNeeded(com.google.cloud.bigquery.TableId tableId,
com.google.cloud.bigquery.Schema bigQuerySchema,
BigQueryClient.CreateTableOptions options)
Creates the table with the given schema, only if it does not exist yet.
|
String |
createTablePathForBigQueryStorage(com.google.cloud.bigquery.TableId tableId)
Creates a String appropriately formatted for BigQuery Storage Write API representing the given
table.
|
com.google.cloud.bigquery.TableInfo |
createTempTable(com.google.cloud.bigquery.TableId destinationTableId,
com.google.cloud.bigquery.Schema schema)
Creates a temporary table with a job to cleanup after application end, and the same location as
the destination table; the temporary table will have the same name as the destination table,
with the current time in milliseconds appended to it; useful for holding temporary data in
order to overwrite the destination table.
|
com.google.cloud.bigquery.TableInfo |
createTempTableAfterCheckingSchema(com.google.cloud.bigquery.TableId destinationTableId,
com.google.cloud.bigquery.Schema schema,
boolean enableModeCheckForSchemaFields) |
com.google.cloud.bigquery.TableId |
createTempTableId(com.google.cloud.bigquery.TableId destinationTableId) |
boolean |
deleteTable(com.google.cloud.bigquery.TableId tableId)
Deletes this table in BigQuery.
|
static String |
fullTableName(com.google.cloud.bigquery.TableId tableId) |
String |
getProjectId() |
com.google.cloud.bigquery.Schema |
getQueryResultSchema(String querySql,
Map<String,String> additionalQueryJobLabels) |
com.google.cloud.bigquery.TableInfo |
getReadTable(BigQueryClient.ReadTableOptions options) |
com.google.cloud.bigquery.Schema |
getReadTableSchema(BigQueryClient.ReadTableOptions options)
Returns the schema of the table/query/view.
|
com.google.cloud.bigquery.TableInfo |
getTable(com.google.cloud.bigquery.TableId tableId) |
Iterable<com.google.cloud.bigquery.Table> |
listTables(com.google.cloud.bigquery.DatasetId datasetId,
com.google.cloud.bigquery.TableDefinition.Type... types) |
com.google.cloud.bigquery.JobStatistics.LoadStatistics |
loadDataIntoTable(BigQueryClient.LoadDataOptions options,
List<String> sourceUris,
com.google.cloud.bigquery.FormatOptions formatOptions,
com.google.cloud.bigquery.JobInfo.WriteDisposition writeDisposition,
Optional<com.google.cloud.bigquery.Schema> schema,
com.google.cloud.bigquery.TableId destinationTable) |
com.google.cloud.bigquery.TableInfo |
materializeQueryToTable(String querySql,
int expirationTimeInMinutes)
Runs the provided query on BigQuery and saves the result in a temporary table.
|
com.google.cloud.bigquery.TableInfo |
materializeQueryToTable(String querySql,
int expirationTimeInMinutes,
Map<String,String> additionalQueryJobLabels)
Runs the provided query on BigQuery and saves the result in a temporary table.
|
com.google.cloud.bigquery.TableInfo |
materializeViewToTable(String querySql,
com.google.cloud.bigquery.TableId viewId,
int expirationTimeInMinutes)
Runs the provided query on BigQuery and saves the result in a temporary table.
|
com.google.cloud.bigquery.Job |
overwriteDestinationWithTemporary(com.google.cloud.bigquery.TableId temporaryTableId,
com.google.cloud.bigquery.TableId destinationTableId)
Overwrites the given destination table, with all the data from the given temporary table,
transactionally.
|
com.google.cloud.bigquery.Job |
overwriteDestinationWithTemporaryDynamicPartitons(com.google.cloud.bigquery.TableId temporaryTableId,
com.google.cloud.bigquery.TableId destinationTableId)
Overwrites the partitions of the destination table, using the partitions from the given
temporary table, transactionally.
|
com.google.cloud.bigquery.TableResult |
query(String sql) |
static void |
runCleanupJobs() |
boolean |
tableExists(com.google.cloud.bigquery.TableId tableId)
Checks whether the requested table exists in BigQuery.
|
com.google.cloud.bigquery.Table |
update(com.google.cloud.bigquery.TableInfo table) |
com.google.cloud.bigquery.JobInfo |
waitForJob(com.google.cloud.bigquery.Job job)
Waits for a BigQuery Job to complete: this is a blocking function.
|
public BigQueryClient(com.google.cloud.bigquery.BigQuery bigQuery,
Optional<String> materializationProject,
Optional<String> materializationDataset,
com.google.common.cache.Cache<String,com.google.cloud.bigquery.TableInfo> destinationTableCache,
Map<String,String> labels,
com.google.cloud.bigquery.QueryJobConfiguration.Priority queryJobPriority,
Optional<BigQueryJobCompletionListener> jobCompletionListener,
long bigQueryJobTimeoutInMinutes)
public static void runCleanupJobs()
public com.google.cloud.bigquery.JobInfo waitForJob(com.google.cloud.bigquery.Job job)
job - The Job to keep track of.public com.google.cloud.bigquery.TableInfo getTable(com.google.cloud.bigquery.TableId tableId)
public boolean tableExists(com.google.cloud.bigquery.TableId tableId)
tableId - The TableId of the requested table in BigQuerypublic com.google.cloud.bigquery.TableInfo createTable(com.google.cloud.bigquery.TableId tableId,
com.google.cloud.bigquery.Schema schema,
BigQueryClient.CreateTableOptions options)
tableId - The TableId of the table to be created.schema - The Schema of the table to be created.options - Allows configuring the created tableTable object representing the table that was created.public com.google.cloud.bigquery.TableInfo createTempTable(com.google.cloud.bigquery.TableId destinationTableId,
com.google.cloud.bigquery.Schema schema)
destinationTableId - The TableId of the eventual destination for the data going into the
temporary table.schema - The Schema of the destination / temporary table.Table object representing the created temporary table.public com.google.cloud.bigquery.TableInfo createTempTableAfterCheckingSchema(com.google.cloud.bigquery.TableId destinationTableId,
com.google.cloud.bigquery.Schema schema,
boolean enableModeCheckForSchemaFields)
throws IllegalArgumentException
IllegalArgumentExceptionpublic com.google.cloud.bigquery.TableId createTempTableId(com.google.cloud.bigquery.TableId destinationTableId)
public boolean deleteTable(com.google.cloud.bigquery.TableId tableId)
tableId - The TableId of the table to be deleted.public com.google.cloud.bigquery.Job overwriteDestinationWithTemporaryDynamicPartitons(com.google.cloud.bigquery.TableId temporaryTableId,
com.google.cloud.bigquery.TableId destinationTableId)
temporaryTableId - The TableId representing the temporary-table.destinationTableId - The TableId representing the destination table.Job object representing this operation (which can be tracked to wait until
it has finished successfully).public com.google.cloud.bigquery.Job overwriteDestinationWithTemporary(com.google.cloud.bigquery.TableId temporaryTableId,
com.google.cloud.bigquery.TableId destinationTableId)
temporaryTableId - The TableId representing the temporary-table.destinationTableId - The TableId representing the destination table.Job object representing this operation (which can be tracked to wait until
it has finished successfully).public com.google.cloud.bigquery.Job appendDestinationWithTemporary(com.google.cloud.bigquery.TableId temporaryTableId,
com.google.cloud.bigquery.TableId destinationTableId)
temporaryTableId - The TableId representing the temporary-table.destinationTableId - The TableId representing the destination table.Job object representing this operation (which can be tracked to wait until
it has finished successfully).public String createTablePathForBigQueryStorage(com.google.cloud.bigquery.TableId tableId)
tableId - The TableId representing the given object.public com.google.cloud.bigquery.TableInfo getReadTable(BigQueryClient.ReadTableOptions options)
public com.google.cloud.bigquery.Schema getReadTableSchema(BigQueryClient.ReadTableOptions options)
options - The ReadTableOptions options for reading the data source.public String getProjectId()
public Iterable<com.google.cloud.bigquery.Table> listTables(com.google.cloud.bigquery.DatasetId datasetId, com.google.cloud.bigquery.TableDefinition.Type... types)
public com.google.cloud.bigquery.Table update(com.google.cloud.bigquery.TableInfo table)
public com.google.cloud.bigquery.Job createAndWaitFor(com.google.cloud.bigquery.JobConfiguration.Builder jobConfiguration)
public com.google.cloud.bigquery.Job createAndWaitFor(com.google.cloud.bigquery.JobConfiguration jobConfiguration)
public com.google.cloud.bigquery.TableResult query(String sql)
public static String fullTableName(com.google.cloud.bigquery.TableId tableId)
public long calculateTableSize(com.google.cloud.bigquery.TableId tableId,
Optional<String> filter)
public long calculateTableSize(com.google.cloud.bigquery.TableInfo tableInfo,
Optional<String> filter)
public com.google.cloud.bigquery.TableInfo materializeQueryToTable(String querySql, int expirationTimeInMinutes)
querySql - the query to be runexpirationTimeInMinutes - the time in minutes until the table is expired and auto-deletedpublic com.google.cloud.bigquery.TableInfo materializeQueryToTable(String querySql, int expirationTimeInMinutes, Map<String,String> additionalQueryJobLabels)
querySql - the query to be runexpirationTimeInMinutes - the time in minutes until the table is expired and auto-deletedadditionalQueryJobLabels - the labels to insert on the query jobpublic com.google.cloud.bigquery.TableInfo materializeViewToTable(String querySql, com.google.cloud.bigquery.TableId viewId, int expirationTimeInMinutes)
querySql - the query to be runviewId - the view the query came fromexpirationTimeInMinutes - the time in hours until the table is expired and auto-deletedpublic com.google.cloud.bigquery.Schema getQueryResultSchema(String querySql, Map<String,String> additionalQueryJobLabels)
public com.google.cloud.bigquery.JobStatistics.LoadStatistics loadDataIntoTable(BigQueryClient.LoadDataOptions options, List<String> sourceUris, com.google.cloud.bigquery.FormatOptions formatOptions, com.google.cloud.bigquery.JobInfo.WriteDisposition writeDisposition, Optional<com.google.cloud.bigquery.Schema> schema, com.google.cloud.bigquery.TableId destinationTable)
public void createTableIfNeeded(com.google.cloud.bigquery.TableId tableId,
com.google.cloud.bigquery.Schema bigQuerySchema,
BigQueryClient.CreateTableOptions options)
Copyright © 2024. All rights reserved.