Package com.google.cloud.bigquery
Class ConnectionSettings.Builder
- java.lang.Object
-
- com.google.cloud.bigquery.ConnectionSettings.Builder
-
- Enclosing class:
- ConnectionSettings
public abstract static class ConnectionSettings.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract ConnectionSettings
build()
Creates aConnectionSettings
object.abstract ConnectionSettings.Builder
setAllowLargeResults(Boolean allowLargeResults)
Sets whether the job is enabled to create arbitrarily large results.abstract ConnectionSettings.Builder
setClustering(Clustering clustering)
Sets the clustering specification for the destination table.abstract ConnectionSettings.Builder
setConnectionProperties(List<ConnectionProperty> connectionProperties)
Sets a connection-level property to customize query behavior.abstract ConnectionSettings.Builder
setCreateDisposition(JobInfo.CreateDisposition createDisposition)
Sets whether the job is allowed to create tables.abstract ConnectionSettings.Builder
setCreateSession(Boolean createSession)
Sets whether to create a new session.abstract ConnectionSettings.Builder
setDefaultDataset(DatasetId datasetId)
Sets the default dataset.abstract ConnectionSettings.Builder
setDestinationEncryptionConfiguration(EncryptionConfiguration destinationEncryptionConfiguration)
Sets the custom encryption configuration (e.g., Cloud KMS keys).abstract ConnectionSettings.Builder
setDestinationTable(TableId destinationTable)
Sets the table where to put query results.abstract ConnectionSettings.Builder
setFlattenResults(Boolean flattenResults)
Sets whether nested and repeated fields should be flattened.abstract ConnectionSettings.Builder
setJobTimeoutMs(Long jobTimeoutMs)
[Optional] Job timeout in milliseconds.abstract ConnectionSettings.Builder
setMaximumBillingTier(Integer maximumBillingTier)
Limits the billing tier for this job.abstract ConnectionSettings.Builder
setMaximumBytesBilled(Long maximumBytesBilled)
Limits the bytes billed for this job.abstract ConnectionSettings.Builder
setMaxResultPerPage(Integer maxResultPerPage)
Sets the maximum records per page to be used for pagination.abstract ConnectionSettings.Builder
setMaxResults(Long maxResults)
Sets the maximum number of rows of data to return per page of results.abstract ConnectionSettings.Builder
setMinResultSize(Integer minResultSize)
Sets the minimum result size for which the Read API will be enabledabstract ConnectionSettings.Builder
setNumBufferedRows(Integer numBufferedRows)
Sets the number of rows in the buffer (a blocking queue) that query results are consumed from.abstract ConnectionSettings.Builder
setPriority(QueryJobConfiguration.Priority priority)
Sets a priority for the query.abstract ConnectionSettings.Builder
setRangePartitioning(RangePartitioning rangePartitioning)
Range partitioning specification for this table.abstract ConnectionSettings.Builder
setRequestTimeout(Long timeoutMs)
Sets how long to wait for the query to complete, in milliseconds, before the request times out and returns.abstract ConnectionSettings.Builder
setSchemaUpdateOptions(List<JobInfo.SchemaUpdateOption> schemaUpdateOptions)
[Experimental] Sets options allowing the schema of the destination table to be updated as a side effect of the query job.abstract ConnectionSettings.Builder
setTableDefinitions(Map<String,ExternalTableDefinition> tableDefinitions)
Sets the external tables definitions.abstract ConnectionSettings.Builder
setTimePartitioning(TimePartitioning timePartitioning)
Sets the time partitioning specification for the destination table.abstract ConnectionSettings.Builder
setTotalToPageRowCountRatio(Integer totalToPageRowCountRatio)
Sets a ratio of the total number of records and the records returned in the current page.abstract ConnectionSettings.Builder
setUseQueryCache(Boolean useQueryCache)
Sets whether to look for the result in the query cache.abstract ConnectionSettings.Builder
setUserDefinedFunctions(List<UserDefinedFunction> userDefinedFunctions)
Sets user defined function resources that can be used by this query.abstract ConnectionSettings.Builder
setUseReadAPI(Boolean useReadAPI)
Sets useReadAPI flag, enabled by default.abstract ConnectionSettings.Builder
setWriteDisposition(JobInfo.WriteDisposition writeDisposition)
Sets the action that should occur if the destination table already exists.
-
-
-
Method Detail
-
setUseReadAPI
@Nullable public abstract ConnectionSettings.Builder setUseReadAPI(Boolean useReadAPI)
Sets useReadAPI flag, enabled by default. Read API will be used if the underlying conditions are satisfied and this flag is enabled- Parameters:
useReadAPI
- ortrue
for none
-
setRequestTimeout
public abstract ConnectionSettings.Builder setRequestTimeout(Long timeoutMs)
Sets how long to wait for the query to complete, in milliseconds, before the request times out and returns. Note that this is only a timeout for the request, not the query. If the query takes longer to run than the timeout value, the call returns without any results and with the 'jobComplete' flag set to false. You can call GetQueryResults() to wait for the query to complete and read the results. The default value is 10000 milliseconds (10 seconds).- Parameters:
timeoutMs
- ornull
for none
-
setConnectionProperties
public abstract ConnectionSettings.Builder setConnectionProperties(List<ConnectionProperty> connectionProperties)
Sets a connection-level property to customize query behavior.- Parameters:
connectionProperties
- connectionProperties ornull
for none
-
setDefaultDataset
public abstract ConnectionSettings.Builder setDefaultDataset(DatasetId datasetId)
Sets the default dataset. This dataset is used for all unqualified table names used in the query.
-
setMaximumBytesBilled
public abstract ConnectionSettings.Builder setMaximumBytesBilled(Long maximumBytesBilled)
Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit will fail (without incurring a charge). If unspecified, this will be set to your project default.- Parameters:
maximumBytesBilled
- maximum bytes billed for this job
-
setMaxResults
public abstract ConnectionSettings.Builder setMaxResults(Long maxResults)
Sets the maximum number of rows of data to return per page of results. Setting this flag to a small value such as 1000 and then paging through results might improve reliability when the query result set is large. In addition to this limit, responses are also limited to 10 MB. By default, there is no maximum row count, and only the byte limit applies.- Parameters:
maxResults
- maxResults ornull
for none
-
setNumBufferedRows
public abstract ConnectionSettings.Builder setNumBufferedRows(Integer numBufferedRows)
Sets the number of rows in the buffer (a blocking queue) that query results are consumed from.- Parameters:
numBufferedRows
- numBufferedRows ornull
for none
-
setTotalToPageRowCountRatio
public abstract ConnectionSettings.Builder setTotalToPageRowCountRatio(Integer totalToPageRowCountRatio)
Sets a ratio of the total number of records and the records returned in the current page. This value is checked before calling the Read API- Parameters:
totalToPageRowCountRatio
- totalToPageRowCountRatio
-
setMinResultSize
public abstract ConnectionSettings.Builder setMinResultSize(Integer minResultSize)
Sets the minimum result size for which the Read API will be enabled- Parameters:
minResultSize
- minResultSize
-
setMaxResultPerPage
public abstract ConnectionSettings.Builder setMaxResultPerPage(Integer maxResultPerPage)
Sets the maximum records per page to be used for pagination. This is used as an input for the tabledata.list and jobs.getQueryResults RPC calls- Parameters:
maxResultPerPage
-
-
setUseQueryCache
public abstract ConnectionSettings.Builder setUseQueryCache(Boolean useQueryCache)
Sets whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. Moreover, the query cache is only available whensetDestinationTable(TableId)
is not set.- See Also:
- Query Caching
-
setFlattenResults
public abstract ConnectionSettings.Builder setFlattenResults(Boolean flattenResults)
Sets whether nested and repeated fields should be flattened. If set tofalse
setAllowLargeResults(Boolean)
must betrue
. By default results are flattened.- See Also:
- Flatten
-
setClustering
public abstract ConnectionSettings.Builder setClustering(Clustering clustering)
Sets the clustering specification for the destination table.
-
setCreateDisposition
public abstract ConnectionSettings.Builder setCreateDisposition(JobInfo.CreateDisposition createDisposition)
Sets whether the job is allowed to create tables.- See Also:
- Create Disposition
-
setDestinationEncryptionConfiguration
public abstract ConnectionSettings.Builder setDestinationEncryptionConfiguration(EncryptionConfiguration destinationEncryptionConfiguration)
Sets the custom encryption configuration (e.g., Cloud KMS keys).- Parameters:
destinationEncryptionConfiguration
- destinationEncryptionConfiguration ornull
for none
-
setDestinationTable
public abstract ConnectionSettings.Builder setDestinationTable(TableId destinationTable)
Sets the table where to put query results. If not provided a new table is created. This value is required ifsetAllowLargeResults(Boolean)
is set totrue
.
-
setJobTimeoutMs
public abstract ConnectionSettings.Builder setJobTimeoutMs(Long jobTimeoutMs)
[Optional] Job timeout in milliseconds. If this time limit is exceeded, BigQuery may attempt to terminate the job.- Parameters:
jobTimeoutMs
- jobTimeoutMs ornull
for none
-
setMaximumBillingTier
public abstract ConnectionSettings.Builder setMaximumBillingTier(Integer maximumBillingTier)
Limits the billing tier for this job. Queries that have resource usage beyond this tier will fail (without incurring a charge). If unspecified, this will be set to your project default.- Parameters:
maximumBillingTier
- maximum billing tier for this job
-
setPriority
public abstract ConnectionSettings.Builder setPriority(QueryJobConfiguration.Priority priority)
Sets a priority for the query. If not specified the priority is assumed to beQueryJobConfiguration.Priority.INTERACTIVE
.
-
setAllowLargeResults
public abstract ConnectionSettings.Builder setAllowLargeResults(Boolean allowLargeResults)
Sets whether the job is enabled to create arbitrarily large results. Iftrue
the query is allowed to create large results at a slight cost in performance. Iftrue
setDestinationTable(TableId)
must be provided.- See Also:
- Returning Large Query Results
-
setCreateSession
public abstract ConnectionSettings.Builder setCreateSession(Boolean createSession)
Sets whether to create a new session. Iftrue
a random session id will be generated by BigQuery. If false, runs query with an existing session_id passed in ConnectionProperty, otherwise runs query in non-session mode."
-
setRangePartitioning
public abstract ConnectionSettings.Builder setRangePartitioning(RangePartitioning rangePartitioning)
Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified.- Parameters:
rangePartitioning
- rangePartitioning ornull
for none
-
setSchemaUpdateOptions
public abstract ConnectionSettings.Builder setSchemaUpdateOptions(List<JobInfo.SchemaUpdateOption> schemaUpdateOptions)
[Experimental] Sets options allowing the schema of the destination table to be updated as a side effect of the query job. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema.
-
setTableDefinitions
public abstract ConnectionSettings.Builder setTableDefinitions(Map<String,ExternalTableDefinition> tableDefinitions)
Sets the external tables definitions. If querying external data sources outside of BigQuery, this value describes the data format, location and other properties of the data sources. By defining these properties, the data sources can be queried as if they were standard BigQuery tables.
-
setTimePartitioning
public abstract ConnectionSettings.Builder setTimePartitioning(TimePartitioning timePartitioning)
Sets the time partitioning specification for the destination table.
-
setUserDefinedFunctions
public abstract ConnectionSettings.Builder setUserDefinedFunctions(List<UserDefinedFunction> userDefinedFunctions)
Sets user defined function resources that can be used by this query. Function resources can either be defined inline (UserDefinedFunction.inline(String)
) or loaded from a Google Cloud Storage URI (UserDefinedFunction.fromUri(String)
.
-
setWriteDisposition
public abstract ConnectionSettings.Builder setWriteDisposition(JobInfo.WriteDisposition writeDisposition)
Sets the action that should occur if the destination table already exists.- See Also:
- Write Disposition
-
build
public abstract ConnectionSettings build()
Creates aConnectionSettings
object.
-
-