The BigQuery ADBC driver wraps a BigQueryClient object for working with Google BigQuery data.
The ADBC driver supports both Service and User accounts for use with BigQuery authentication.
The ADBC driver passes the configured credentials to BigQuery, but you may need to ensure the credentials have proper authorization to perform operations such as read and write.
The following parameters can be used to configure the driver behavior. The parameters are case sensitive.
adbc.bigquery.access_token
Sets the access token to use as the credential. Currently, this is for Microsoft Entra, but this could be used for other OAuth implementations as well.
adbc.bigquery.audience_uri
Sets the audience URI for the authentication token. Currently, this is for Microsoft Entra, but this could be used for other OAuth implementations as well.
adbc.bigquery.allow_large_results
Sets the AllowLargeResults value of the QueryOptions to true if configured; otherwise, the default is false.
adbc.bigquery.auth_type
Required. Must be user, aad (for Microsoft Entra) or service.
adbc.bigquery.billing_project_id
The Project ID used for accessing billing BigQuery. If not specified, will default to the detected project ID.
adbc.bigquery.client_id
The OAuth client ID. Required for user authentication.
adbc.bigquery.client_secret
The OAuth client secret. Required for user authentication.
adbc.bigquery.client.timeout
Optional. Sets the timeout (in seconds) for the BigQueryClient. Similar to a ConnectionTimeout.
adbc.bigquery.auth_json_credential
Required if using service authentication. This value is passed to the GoogleCredential.FromJson method.
adbc.bigquery.get_query_results_options.timeout
Optional. Sets the timeout (in seconds) for the GetQueryResultsOptions value. If not set, defaults to 5 minutes. Similar to a CommandTimeout.
adbc.bigquery.maximum_retries
Optional. The maximum number of retries. Defaults to 5.
adbc.bigquery.max_fetch_concurrency
Optional. Sets the maxStreamCount for the CreateReadSession method. If not set, defaults to 1.
adbc.bigquery.multiple_statement.statement_type
Optional. When executing multiple statements, limit the type of statement returned. If not set, all types of statements are returned.
adbc.bigquery.multiple_statement.statement_index
Optional. When executing multiple statements, specify the result of the statement to be returned (Minimum value is 1). If not set, the result of the first statement is returned.
adbc.bigquery.multiple_statement.evaluation_kind
Optional. When executing multiple statements, limit the evaluation kind returned. If not set, all evaluation kinds are returned.
adbc.bigquery.include_constraints_getobjects
Optional. Some callers do not need the constraint details when they get the table information and can improve the speed of obtaining the results. Setting this value to "false" will not include the constraint details. The default value is "true".
adbc.bigquery.include_public_project_id
Include the bigquery-public-data project ID with the list of project IDs.
adbc.bigquery.large_results_dataset
Optional. Sets the dataset ID to use for large results. The dataset needs to be in the same region as the data being queried. If no value is specified, the driver will attempt to use or create _bqadbc_temp_tables. A randomly generated table name will be used for the DestinationTable.
adbc.bigquery.large_results_destination_table
Optional. Sets the DestinationTable value of the QueryOptions if configured. Expects the format to be {projectId}.{datasetId}.{tableId} to set the corresponding values in the TableReference class.
adbc.bigquery.project_id
The Project ID used for accessing BigQuery. If not specified, will default to detect the projectIds the credentials have access to.
adbc.bigquery.refresh_token
The refresh token used for when the generated OAuth token expires. Required for user authentication.
adbc.bigquery.retry_delay_ms
Optional The delay between retries. Defaults to 200ms. The retries could take up to adbc.bigquery.maximum_retries x adbc.bigquery.retry_delay_ms to complete.
adbc.bigquery.scopes
Optional. Comma separated list of scopes to include for the credential.
adbc.bigquery.use_legacy_sql
Sets the UseLegacySql value of the QueryOptions to true if configured; otherwise, the default is false.
There are some limitations to both C# and the C# Arrow implementation that limit how BigQuery data types that can be represented by the ADBC driver. For example, the BIGNUMERIC type in BigQuery does not have a large value equivalent to C#.
The following table depicts how the BigQuery ADBC driver converts a BigQuery type to an Arrow type.
| BigQuery Type | Arrow Type | C# Type |----------|:-------------:| | BIGNUMERIC | Decimal256 | string | BOOL | Boolean | bool | BYTES | Binary | byte[] | DATE | Date32 | DateTime | DATETIME | Timestamp | DateTime | FLOAT64 | Double | double | GEOGRAPHY | String | string | INT64 | Int64 | long | NUMERIC | Decimal128 | SqlDecimal | STRING | String | string | STRUCT | String+ | string | TIME |Time64 | long | TIMESTAMP | Timestamp | DateTimeOffset
+A JSON string
See Arrow Schema Details for how BigQuery handles Arrow types.
The driver supports authenticating with a Microsoft Entra ID. For long running operations, the Entra token may timeout if the operation takes longer than the Entra token's lifetime. The driver has the ability to perform token refreshes by subscribing to the UpdateToken delegate on the BigQueryConnection. In this scenario, the driver will attempt to perform an operation. If that operation fails due to an Unauthorized error, then the token will be refreshed via the UpdateToken delegate.
Sample code to refresh the token:
Dictionary<string,string> properties = ...;
BigQueryConnection connection = new BigQueryConnection(properties);
connection.UpdateToken = () => Task.Run(() =>
{
connection.SetOption(BigQueryParameters.AccessToken, GetAccessToken());
});
In the sample above, when a new token is needed, the delegate is invoked and updates the adbc.bigquery.access_token parameter on the connection object.
If a adbc.bigquery.project_id is not specified, or if it equals bigquery-public-data, the driver will query for the first project ID that is associated with the credentials provided. This will be the project ID that is used to perform queries.
If a result set will contain large results, the adbc.bigquery.allow_large_results parameter should be set to "true". If this value is set, a destination must be specified. The caller can either explicitly specify the fully qualified name of the destination table using the adbc.bigquery.large_results_destination_table value, or they can specify a dataset using the adbc.bigquery.large_results_dataset parameter.
Behavior:
_bqadbc_temp_tables dataset using the same defaults and label specified above. A randomly generated name will be used for the table name.The ADBC driver uses the BigQuery Client APIs to communicate with BigQuery. The following actions are performed in the driver and require the calling user to have the specified permissions. For more details on the permissions, or what roles may already have the permissions required, please see the additional references section below.
| Action | Permissions Required |
|---|---|
| Create Dataset*+ | bigquery.datasets.create |
| Create Query Job | bigquery.jobs.create |
| Create Read Session | bigquery.readsessions.create bigquery.tables.getData |
| Execute Query | bigquery.jobs.create bigquery.jobs.get bigquery.jobs.list |
| Get Dataset* | bigquery.datasets.get |
| Get Job | bigquery.jobs.get |
| Get Query Results | bigquery.jobs.get |
| List Jobs | bigquery.jobs.list |
| Read Rows | bigquery.readsessions.getData |
Some environments may also require:
Additional References:
To enable tracing messages to be observed, a tracing exporter needs to be activated. Use either the environment variable OTEL_TRACES_EXPORTER or the parameter adbc.traces.exporter to select one of the supported exporters. The parameter has precedence over the environment variable. The parameter must be set before the connection is initialized.
The following exporters are supported:
| Exporter | Description |
|---|---|
adbcfile | Exports traces to rotating files in a folder. |
Rotating trace files are written to a folder. The file names are created with the following pattern: apache.arrow.adbc.drivers.bigquery-<YYYY-MM-DD-HH-mm-ss-fff>-<process-id>.log.
The folder used depends on the platform.
| Platform | Folder |
|---|---|
| Windows | %LOCALAPPDATA%/Apache.Arrow.Adbc/Traces |
| macOS | $HOME/Library/Application Support/Apache.Arrow.Adbc/Traces |
| Linux | $HOME/.local/share/Apache.Arrow.Adbc/Traces |
By default, up to 999 files of maximum size 1024 KB are written to the trace folder.