bigquery-adbc 0.1.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bigquery_adbc/__init__.py +146 -0
- bigquery_adbc/_options.py +431 -0
- bigquery_adbc/adbc_driver_bigquery.dll +0 -0
- bigquery_adbc/dbapi.py +173 -0
- bigquery_adbc/py.typed +1 -0
- bigquery_adbc-0.1.0.dist-info/METADATA +262 -0
- bigquery_adbc-0.1.0.dist-info/RECORD +13 -0
- bigquery_adbc-0.1.0.dist-info/WHEEL +5 -0
- bigquery_adbc-0.1.0.dist-info/licenses/LICENSE +201 -0
- bigquery_adbc-0.1.0.dist-info/licenses/NOTICE +25 -0
- bigquery_adbc-0.1.0.dist-info/licenses/licenses/RUST-STD.html +29357 -0
- bigquery_adbc-0.1.0.dist-info/licenses/licenses/THIRD_PARTY_LICENSES.txt +30106 -0
- bigquery_adbc-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Python bindings for the BigQuery ADBC driver."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
import importlib.metadata
|
|
7
|
+
import os
|
|
8
|
+
from collections.abc import Mapping
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import adbc_driver_manager
|
|
12
|
+
|
|
13
|
+
from ._options import (
|
|
14
|
+
AuthenticationType,
|
|
15
|
+
BulkIngestMethod,
|
|
16
|
+
ConnectionOptions,
|
|
17
|
+
CreateDisposition,
|
|
18
|
+
CredentialsType,
|
|
19
|
+
DatabaseOptions,
|
|
20
|
+
ParameterMode,
|
|
21
|
+
QueryPriority,
|
|
22
|
+
StatementOptions,
|
|
23
|
+
WriteDisposition,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
ENTRYPOINT = "AdbcDriverBigqueryInit"
|
|
27
|
+
|
|
28
|
+
_DISTRIBUTION_NAME = "bigquery-adbc"
|
|
29
|
+
_LIBRARY_ENV = "BIGQUERY_ADBC_LIBRARY"
|
|
30
|
+
_LIBRARY_FILENAMES = (
|
|
31
|
+
"libadbc_driver_bigquery.so",
|
|
32
|
+
"libadbc_driver_bigquery.dylib",
|
|
33
|
+
"adbc_driver_bigquery.dll",
|
|
34
|
+
)
|
|
35
|
+
_PACKAGE_DIR = Path(__file__).resolve().parent
|
|
36
|
+
# The option values adbc_driver_manager accepts: a bool becomes "true" or "false", an int,
|
|
37
|
+
# float or bytes value sets a typed option, and a path is passed as its string.
|
|
38
|
+
_OptionValue = str | bytes | int | float | Path
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
__version__ = importlib.metadata.version(_DISTRIBUTION_NAME)
|
|
42
|
+
except importlib.metadata.PackageNotFoundError:
|
|
43
|
+
# Only an uninstalled source tree lacks distribution metadata.
|
|
44
|
+
__version__ = "0.0.0+unknown"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _validated_library_path(path: Path, source: str) -> str:
|
|
48
|
+
try:
|
|
49
|
+
is_file = path.is_file()
|
|
50
|
+
except OSError as error:
|
|
51
|
+
raise FileNotFoundError(
|
|
52
|
+
f"Could not inspect the BigQuery ADBC driver library from {source}: {path} ({error})"
|
|
53
|
+
) from error
|
|
54
|
+
|
|
55
|
+
if not is_file:
|
|
56
|
+
raise FileNotFoundError(f"The BigQuery ADBC driver library from {source} is not a regular file: {path}")
|
|
57
|
+
|
|
58
|
+
return str(path.resolve(strict=True))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@functools.lru_cache(maxsize=1)
|
|
62
|
+
def _bundled_library_path(package_dir: Path) -> str:
|
|
63
|
+
"""Resolve once per package directory; installed libraries are immutable."""
|
|
64
|
+
|
|
65
|
+
candidates = [path for filename in _LIBRARY_FILENAMES if (path := package_dir / filename).is_file()]
|
|
66
|
+
if not candidates:
|
|
67
|
+
expected = ", ".join(_LIBRARY_FILENAMES)
|
|
68
|
+
raise FileNotFoundError(
|
|
69
|
+
"No bundled BigQuery ADBC driver library was found beside the Python "
|
|
70
|
+
f"package (expected one of: {expected}). Install a platform wheel, or "
|
|
71
|
+
f"set {_LIBRARY_ENV} to an absolute path for development."
|
|
72
|
+
)
|
|
73
|
+
if len(candidates) > 1:
|
|
74
|
+
found = ", ".join(path.name for path in candidates)
|
|
75
|
+
raise RuntimeError(f"Expected exactly one bundled BigQuery ADBC driver library, but found: {found}")
|
|
76
|
+
|
|
77
|
+
return _validated_library_path(candidates[0], "the installed Python package")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def driver_path() -> str:
|
|
81
|
+
"""Return the absolute path of the native BigQuery ADBC driver library.
|
|
82
|
+
|
|
83
|
+
``BIGQUERY_ADBC_LIBRARY``, if set, names a development build to use instead of
|
|
84
|
+
the library bundled beside this module. It is read on every call, so a running
|
|
85
|
+
session can switch builds; the bundled path is cached.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
override = os.environ.get(_LIBRARY_ENV)
|
|
89
|
+
if override:
|
|
90
|
+
return _validated_library_path(Path(override).expanduser(), f"the {_LIBRARY_ENV} environment variable")
|
|
91
|
+
|
|
92
|
+
return _bundled_library_path(_PACKAGE_DIR)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def connect(
|
|
96
|
+
uri: str | None = None,
|
|
97
|
+
# Mapping keys are invariant, so enum-keyed mappings need their own member.
|
|
98
|
+
db_kwargs: Mapping[str, _OptionValue] | Mapping[DatabaseOptions, _OptionValue] | None = None,
|
|
99
|
+
) -> adbc_driver_manager.AdbcDatabase:
|
|
100
|
+
"""Create a low-level ADBC database for BigQuery.
|
|
101
|
+
|
|
102
|
+
Configure the driver with ``uri``, ``db_kwargs``, or both. Explicit options
|
|
103
|
+
override URI parameters. Omitting ``uri`` leaves the native option unset.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
options: dict[str, _OptionValue] = dict(db_kwargs.items()) if db_kwargs else {}
|
|
107
|
+
configured_uri = options.get(DatabaseOptions.URI)
|
|
108
|
+
if uri is not None and configured_uri is not None and configured_uri != uri:
|
|
109
|
+
raise ValueError(
|
|
110
|
+
"Conflicting BigQuery URIs were provided as 'uri' and db_kwargs['uri']; "
|
|
111
|
+
"provide the URI once, or use the same value in both places"
|
|
112
|
+
)
|
|
113
|
+
reserved = {"driver", "entrypoint"}.intersection(options)
|
|
114
|
+
if reserved:
|
|
115
|
+
names = ", ".join(sorted(reserved))
|
|
116
|
+
raise ValueError(
|
|
117
|
+
f"db_kwargs must not set {names}: bigquery_adbc.connect() supplies the "
|
|
118
|
+
f"bundled driver library path and the {ENTRYPOINT} entrypoint. Set "
|
|
119
|
+
f"{_LIBRARY_ENV} to load a different library."
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
if uri is not None:
|
|
123
|
+
options[DatabaseOptions.URI] = uri
|
|
124
|
+
return adbc_driver_manager.AdbcDatabase(
|
|
125
|
+
driver=driver_path(),
|
|
126
|
+
entrypoint=ENTRYPOINT,
|
|
127
|
+
**options,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
__all__ = [
|
|
132
|
+
"ENTRYPOINT",
|
|
133
|
+
"AuthenticationType",
|
|
134
|
+
"BulkIngestMethod",
|
|
135
|
+
"ConnectionOptions",
|
|
136
|
+
"CreateDisposition",
|
|
137
|
+
"CredentialsType",
|
|
138
|
+
"DatabaseOptions",
|
|
139
|
+
"ParameterMode",
|
|
140
|
+
"QueryPriority",
|
|
141
|
+
"StatementOptions",
|
|
142
|
+
"WriteDisposition",
|
|
143
|
+
"__version__",
|
|
144
|
+
"connect",
|
|
145
|
+
"driver_path",
|
|
146
|
+
]
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
"""Typed option names and values supported by the BigQuery driver.
|
|
2
|
+
|
|
3
|
+
Generated from compiled Rust option metadata; run
|
|
4
|
+
``cargo run --locked --features python-option-codegen --bin generate-python-options``
|
|
5
|
+
after changing an option declaration. Do not edit this file manually.
|
|
6
|
+
|
|
7
|
+
Every enum is a string: dictionary keys, option values, ``str()``, and formatting
|
|
8
|
+
all use its wire value on every supported Python version.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import enum
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DatabaseOptions(enum.StrEnum):
|
|
17
|
+
"""Options accepted while initializing an ADBC database."""
|
|
18
|
+
|
|
19
|
+
#: The standard ADBC connection URI, `bigquery:///<project>?<key>=<value>`. Optional: every
|
|
20
|
+
#: setting a URI carries also has an option of its own.
|
|
21
|
+
URI = "uri"
|
|
22
|
+
|
|
23
|
+
#: How the driver authenticates: an `AuthenticationType` value. Unset resolves Google Cloud
|
|
24
|
+
#: Application Default Credentials.
|
|
25
|
+
AUTHENTICATION_TYPE = "bigquery.auth_type"
|
|
26
|
+
|
|
27
|
+
#: The JSON credential file path or credential document selected by `AUTHENTICATION_TYPE`.
|
|
28
|
+
#: Write-only and redacted from debug output; an error may quote a file path, never a
|
|
29
|
+
#: document.
|
|
30
|
+
AUTHENTICATION_CREDENTIALS = "bigquery.auth.credentials"
|
|
31
|
+
|
|
32
|
+
#: An optional `CredentialsType` value the JSON credential's `type` field must match; a
|
|
33
|
+
#: mismatch is rejected. It does not change how the document is parsed.
|
|
34
|
+
AUTHENTICATION_CREDENTIALS_TYPE = "bigquery.auth.credentials_type"
|
|
35
|
+
|
|
36
|
+
#: The OAuth client ID required by `user_authentication`.
|
|
37
|
+
AUTHENTICATION_CLIENT_ID = "bigquery.auth.client_id"
|
|
38
|
+
|
|
39
|
+
#: The OAuth client secret required by `user_authentication`. Write-only.
|
|
40
|
+
AUTHENTICATION_CLIENT_SECRET = "bigquery.auth.client_secret"
|
|
41
|
+
|
|
42
|
+
#: The OAuth refresh token required by `user_authentication`. Write-only.
|
|
43
|
+
AUTHENTICATION_REFRESH_TOKEN = "bigquery.auth.refresh_token"
|
|
44
|
+
|
|
45
|
+
#: The OAuth access token `temporary_access_token` sends as-is. Write-only. The driver never
|
|
46
|
+
#: refreshes it, so requests fail once it expires.
|
|
47
|
+
AUTHENTICATION_ACCESS_TOKEN = "bigquery.auth.access_token"
|
|
48
|
+
|
|
49
|
+
#: The OAuth token endpoint `user_authentication` redeems the refresh token at; unset uses
|
|
50
|
+
#: Google's default.
|
|
51
|
+
AUTHENTICATION_ACCESS_TOKEN_ENDPOINT = "bigquery.auth.access_token_endpoint"
|
|
52
|
+
|
|
53
|
+
#: The Workload Identity Federation provider resource required by `external_account`.
|
|
54
|
+
AUTHENTICATION_EXTERNAL_ACCOUNT_AUDIENCE = "bigquery.auth.external_account.audience"
|
|
55
|
+
|
|
56
|
+
#: The OAuth identity-provider URL required by `external_account`. Write-only, because its
|
|
57
|
+
#: query can carry secrets. HTTPS is required unless `ALLOW_UNTRUSTED_ENDPOINT` is set.
|
|
58
|
+
AUTHENTICATION_EXTERNAL_ACCOUNT_REQUEST_URL = "bigquery.auth.external_account.request_url"
|
|
59
|
+
|
|
60
|
+
#: The already form-encoded identity-provider POST body required by `external_account`, sent
|
|
61
|
+
#: unchanged. Write-only.
|
|
62
|
+
AUTHENTICATION_EXTERNAL_ACCOUNT_REQUEST_DATA = "bigquery.auth.external_account.request_data"
|
|
63
|
+
|
|
64
|
+
#: An optional standard IAM Credentials `generateAccessToken` URL for `external_account`.
|
|
65
|
+
AUTHENTICATION_EXTERNAL_ACCOUNT_IMPERSONATION_URL = "bigquery.auth.external_account.impersonation_url"
|
|
66
|
+
|
|
67
|
+
#: How Google's Security Token Service interprets the token the identity provider returns:
|
|
68
|
+
#: `urn:ietf:params:oauth:token-type:jwt`, the default, or
|
|
69
|
+
#: `urn:ietf:params:oauth:token-type:access_token` for an opaque token.
|
|
70
|
+
AUTHENTICATION_EXTERNAL_ACCOUNT_SUBJECT_TOKEN_TYPE = "bigquery.auth.external_account.subject_token_type"
|
|
71
|
+
|
|
72
|
+
#: Overrides `https://sts.googleapis.com/v1/token`, where the `external_account` subject
|
|
73
|
+
#: token is exchanged. An override must still be HTTPS on `googleapis.com` unless
|
|
74
|
+
#: `ALLOW_UNTRUSTED_ENDPOINT` is set.
|
|
75
|
+
AUTHENTICATION_EXTERNAL_ACCOUNT_TOKEN_URL = "bigquery.auth.external_account.token_url"
|
|
76
|
+
|
|
77
|
+
#: The project API quota and billing are attributed to, applied to the shared credentials.
|
|
78
|
+
AUTHENTICATION_QUOTA_PROJECT = "bigquery.auth.quota_project"
|
|
79
|
+
|
|
80
|
+
#: Comma-separated base OAuth scopes. Without an impersonation layer, unset falls back to
|
|
81
|
+
#: `IMPERSONATION_SCOPES`, then the credential default: `cloud-platform` for service
|
|
82
|
+
#: accounts, or the original consent grant for user credentials. User credentials can
|
|
83
|
+
#: request a subset of their consented scopes. External tables over Google Sheets or Drive
|
|
84
|
+
#: also need `https://www.googleapis.com/auth/drive`, with prior consent for user
|
|
85
|
+
#: credentials.
|
|
86
|
+
AUTHENTICATION_SCOPES = "bigquery.auth.scopes"
|
|
87
|
+
|
|
88
|
+
#: The project queries run and are billed in. Only a database sets it; on a connection it
|
|
89
|
+
#: reads back the current catalog.
|
|
90
|
+
PROJECT_ID = "bigquery.project_id"
|
|
91
|
+
|
|
92
|
+
#: The initial dataset unqualified table names resolve in. Only a database sets it; on a
|
|
93
|
+
#: connection it reads back the current schema.
|
|
94
|
+
DATASET_ID = "bigquery.dataset_id"
|
|
95
|
+
|
|
96
|
+
#: Overrides `https://bigquery.googleapis.com`, the BigQuery REST endpoint. A bare
|
|
97
|
+
#: `host[:port]` is HTTPS; an emulator needs an explicit `http://`. Set as an option, the
|
|
98
|
+
#: endpoint is trusted to receive credentials on any host and scheme, unlike the host of a
|
|
99
|
+
#: `bigquery://` URI.
|
|
100
|
+
ENDPOINT = "bigquery.endpoint"
|
|
101
|
+
|
|
102
|
+
#: Overrides the BigQuery Storage API endpoint, shared by the Read and Write halves of that
|
|
103
|
+
#: API.
|
|
104
|
+
STORAGE_ENDPOINT = "bigquery.storage_endpoint"
|
|
105
|
+
|
|
106
|
+
#: Overrides `https://storage.googleapis.com`, the Cloud Storage JSON API host the
|
|
107
|
+
#: python-model upload is sent to.
|
|
108
|
+
GCS_ENDPOINT = "bigquery.gcs_endpoint"
|
|
109
|
+
|
|
110
|
+
#: Overrides `https://{region}-dataproc.googleapis.com`, the regional Dataproc host. An
|
|
111
|
+
#: override replaces the whole host, region included.
|
|
112
|
+
DATAPROC_ENDPOINT = "bigquery.dataproc_endpoint"
|
|
113
|
+
|
|
114
|
+
#: Overrides `https://{region}-aiplatform.googleapis.com`, the regional Vertex AI host. An
|
|
115
|
+
#: override replaces the whole host, region included.
|
|
116
|
+
VERTEX_ENDPOINT = "bigquery.vertex_endpoint"
|
|
117
|
+
|
|
118
|
+
#: Boolean string, default `false`: permits a `bigquery://` URI host, auxiliary service and
|
|
119
|
+
#: credential-exchange endpoint overrides, and credential-document destinations that are not
|
|
120
|
+
#: HTTPS Google API hosts. A BigQuery REST endpoint set as an option is already explicitly
|
|
121
|
+
#: trusted. It cannot be set through a URI.
|
|
122
|
+
ALLOW_UNTRUSTED_ENDPOINT = "bigquery.allow_untrusted_endpoint"
|
|
123
|
+
|
|
124
|
+
#: The comma-separated service-account delegation chain used to impersonate.
|
|
125
|
+
IMPERSONATION_DELEGATES = "bigquery.impersonate.delegates"
|
|
126
|
+
|
|
127
|
+
#: The impersonated token's lifetime, a positive Go duration up to 12 hours; unset is one
|
|
128
|
+
#: hour. Over one hour also needs an organization policy, which IAM checks at the first
|
|
129
|
+
#: query.
|
|
130
|
+
IMPERSONATION_LIFETIME = "bigquery.impersonate.lifetime"
|
|
131
|
+
|
|
132
|
+
#: Comma-separated OAuth scopes for the impersonated token. Without an impersonation layer,
|
|
133
|
+
#: also the base credential's fallback when `AUTHENTICATION_SCOPES` is unset. Discrete
|
|
134
|
+
#: external-account credentials use that fallback even with an impersonation layer. Scopes
|
|
135
|
+
#: alone do not turn impersonation on; temporary access tokens remain unchanged.
|
|
136
|
+
IMPERSONATION_SCOPES = "bigquery.impersonate.scopes"
|
|
137
|
+
|
|
138
|
+
#: The service account to impersonate; required when delegates or a lifetime are configured.
|
|
139
|
+
#: Scopes alone do not enable impersonation.
|
|
140
|
+
IMPERSONATION_TARGET_PRINCIPAL = "bigquery.impersonate.target_principal"
|
|
141
|
+
|
|
142
|
+
#: The default location applied to every query and transaction path.
|
|
143
|
+
LOCATION = "bigquery.location"
|
|
144
|
+
|
|
145
|
+
#: Text such as `my-app/1.0` appended to the `bigquery-adbc/<version>` user agent of REST
|
|
146
|
+
#: and Storage Read requests, which Cloud Audit Logs record.
|
|
147
|
+
USER_AGENT = "bigquery.user_agent"
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class ConnectionOptions(enum.StrEnum):
|
|
151
|
+
"""Options accepted by an ADBC connection."""
|
|
152
|
+
|
|
153
|
+
#: Standard ADBC boolean string. With `false`, the first query that needs a session opens
|
|
154
|
+
#: one for the transaction, kept until autocommit is re-enabled or the connection is
|
|
155
|
+
#: released.
|
|
156
|
+
AUTOCOMMIT = "adbc.connection.autocommit"
|
|
157
|
+
|
|
158
|
+
#: Standard ADBC current catalog: the project unqualified names resolve in. A connection
|
|
159
|
+
#: also reports it under `DatabaseOptions.PROJECT_ID`.
|
|
160
|
+
CURRENT_CATALOG = "adbc.connection.catalog"
|
|
161
|
+
|
|
162
|
+
#: Standard ADBC current schema: the dataset unqualified names resolve in. A connection also
|
|
163
|
+
#: reports it under `DatabaseOptions.DATASET_ID`.
|
|
164
|
+
CURRENT_DB_SCHEMA = "adbc.connection.db_schema"
|
|
165
|
+
|
|
166
|
+
#: Standard ADBC boolean string. Only `false` is supported; use IAM permissions to restrict
|
|
167
|
+
#: writes.
|
|
168
|
+
READ_ONLY = "adbc.connection.readonly"
|
|
169
|
+
|
|
170
|
+
#: Standard ADBC transaction isolation level. Accepts
|
|
171
|
+
#: `adbc.connection.transaction.isolation.default` or
|
|
172
|
+
#: `adbc.connection.transaction.isolation.snapshot`; always reports the latter.
|
|
173
|
+
ISOLATION_LEVEL = "adbc.connection.transaction.isolation_level"
|
|
174
|
+
|
|
175
|
+
#: The bulk-ingest implementation: a `BulkIngestMethod` value.
|
|
176
|
+
BULK_INGEST_METHOD = "bigquery.bulk_ingest.method"
|
|
177
|
+
|
|
178
|
+
#: Boolean string, default `true`: list tables without fetching their constraints. Setting
|
|
179
|
+
#: `false` includes constraints at tables depth. Column/all depth is unaffected.
|
|
180
|
+
GET_OBJECTS_SKIP_TABLE_METADATA = "bigquery.get_objects.skip_table_metadata"
|
|
181
|
+
|
|
182
|
+
#: Boolean string, default `false`: match GetObjects filters as exact, case-sensitive names,
|
|
183
|
+
#: treating `%` and `_` literally. GetStatistics is unaffected.
|
|
184
|
+
GET_OBJECTS_DISABLE_WILDCARDS = "bigquery.get_objects.disable_wildcards"
|
|
185
|
+
|
|
186
|
+
#: The maximum number of REST row batches one reader converts concurrently: a positive
|
|
187
|
+
#: integer, default `10`, also capped by available parallelism. Storage Read ignores it.
|
|
188
|
+
QUERY_PREFETCH_CONCURRENCY = "bigquery.query.prefetch_concurrency"
|
|
189
|
+
|
|
190
|
+
#: Boolean string, default `false`: lets the Storage Read path read several streams in
|
|
191
|
+
#: parallel and return batches as they arrive, ignoring `ORDER BY`. Rows are never lost or
|
|
192
|
+
#: duplicated.
|
|
193
|
+
QUERY_UNORDERED_READ = "bigquery.query.unordered_read"
|
|
194
|
+
|
|
195
|
+
#: Boolean string, default `false`: forces query results through REST when `true`. Reports
|
|
196
|
+
#: the configured value even after automatic fallback. Setting `false` on a connection also
|
|
197
|
+
#: clears the billing project's cached Storage Read refusal.
|
|
198
|
+
QUERY_USE_STORAGE_API_DISABLED_CLIENT = "bigquery.query.use_storage_api_disabled_client"
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class StatementOptions(enum.StrEnum):
|
|
202
|
+
"""Options accepted by an ADBC statement."""
|
|
203
|
+
|
|
204
|
+
#: Standard ADBC boolean string, and the portable spelling of `QUERY_PARAMETER_MODE`: `true`
|
|
205
|
+
#: binds parameters by the bound stream's field names, `false` by position. The two options
|
|
206
|
+
#: read each other back.
|
|
207
|
+
BIND_BY_NAME = "adbc.statement.bind_by_name"
|
|
208
|
+
|
|
209
|
+
#: The bulk-ingest implementation: a `BulkIngestMethod` value.
|
|
210
|
+
BULK_INGEST_METHOD = "bigquery.bulk_ingest.method"
|
|
211
|
+
|
|
212
|
+
#: Whether the query may create its destination table: a `CreateDisposition` value.
|
|
213
|
+
QUERY_CREATE_DISPOSITION = "bigquery.query.create_disposition"
|
|
214
|
+
|
|
215
|
+
#: Boolean string: asks BigQuery to create a session, independently of the sessions ADBC
|
|
216
|
+
#: transactions use.
|
|
217
|
+
QUERY_CREATE_SESSION = "bigquery.query.create_session"
|
|
218
|
+
|
|
219
|
+
#: The dataset unqualified names resolve in for this statement; empty restores the
|
|
220
|
+
#: connection's current schema.
|
|
221
|
+
QUERY_DEFAULT_DATASET_ID = "bigquery.query.default_dataset_id"
|
|
222
|
+
|
|
223
|
+
#: The project of this statement's default dataset; empty restores the connection's current
|
|
224
|
+
#: catalog.
|
|
225
|
+
QUERY_DEFAULT_PROJECT_ID = "bigquery.query.default_project_id"
|
|
226
|
+
|
|
227
|
+
#: Where the query writes its result, as `[[project.]dataset.]table` completed from the
|
|
228
|
+
#: effective defaults; empty clears it.
|
|
229
|
+
QUERY_DESTINATION_TABLE = "bigquery.query.destination_table"
|
|
230
|
+
|
|
231
|
+
#: Boolean string: when true the query does not use BigQuery's query cache.
|
|
232
|
+
QUERY_DISABLE_QUERY_CACHE = "bigquery.query.disable_query_cache"
|
|
233
|
+
|
|
234
|
+
#: Boolean string: validates the statement without running it, returning an empty stream
|
|
235
|
+
#: with the inferred schema. `execute_partitions` rejects it with `INVALID_STATE`.
|
|
236
|
+
QUERY_DRY_RUN = "bigquery.query.dry_run"
|
|
237
|
+
|
|
238
|
+
#: The job timeout in milliseconds; zero clears the override and a negative value is
|
|
239
|
+
#: rejected.
|
|
240
|
+
QUERY_JOB_TIMEOUT = "bigquery.query.job_timeout"
|
|
241
|
+
|
|
242
|
+
#: Reservation resource name
|
|
243
|
+
#: `projects/{project}/locations/{location}/reservations/{reservation}`. Empty clears the
|
|
244
|
+
#: override; `none` requests on-demand billing when permitted by the project's or
|
|
245
|
+
#: organization's reservation override policy. BigQuery validates the value.
|
|
246
|
+
QUERY_RESERVATION = "bigquery.query.reservation"
|
|
247
|
+
|
|
248
|
+
#: A JSON object of string labels for every query job, such as `{"team":"data"}`; empty or
|
|
249
|
+
#: `{}` clears them, and `key=value` or comma-separated strings are rejected. Reads back as
|
|
250
|
+
#: canonical JSON sorted by key.
|
|
251
|
+
QUERY_LABELS = "bigquery.query.labels"
|
|
252
|
+
|
|
253
|
+
#: Boolean string accepted for Go-driver compatibility, but a no-op: a failed job's error
|
|
254
|
+
#: message ends with its console link either way.
|
|
255
|
+
QUERY_LINK_FAILED_JOB = "bigquery.query.link_failed_job"
|
|
256
|
+
|
|
257
|
+
#: Recognized but returns `NOT_IMPLEMENTED`, because Google deprecated the field. Cap cost
|
|
258
|
+
#: with `QUERY_MAXIMUM_BYTES_BILLED` instead.
|
|
259
|
+
QUERY_MAXIMUM_BILLING_TIER = "bigquery.query.max_billing_tier"
|
|
260
|
+
|
|
261
|
+
#: The maximum bytes the query may bill; zero clears the override and a negative value is
|
|
262
|
+
#: rejected.
|
|
263
|
+
QUERY_MAXIMUM_BYTES_BILLED = "bigquery.query.max_bytes_billed"
|
|
264
|
+
|
|
265
|
+
#: How bound parameters are sent: a `ParameterMode` value, `positional` by default.
|
|
266
|
+
QUERY_PARAMETER_MODE = "bigquery.query.parameter_mode"
|
|
267
|
+
|
|
268
|
+
#: Overrides `ConnectionOptions.QUERY_PREFETCH_CONCURRENCY` for one statement.
|
|
269
|
+
QUERY_PREFETCH_CONCURRENCY = "bigquery.query.prefetch_concurrency"
|
|
270
|
+
|
|
271
|
+
#: The query's scheduling priority: a `QueryPriority` value.
|
|
272
|
+
QUERY_PRIORITY = "bigquery.query.priority"
|
|
273
|
+
|
|
274
|
+
#: Overrides `ConnectionOptions.QUERY_UNORDERED_READ` for one statement.
|
|
275
|
+
QUERY_UNORDERED_READ = "bigquery.query.unordered_read"
|
|
276
|
+
|
|
277
|
+
#: Overrides `ConnectionOptions.QUERY_USE_STORAGE_API_DISABLED_CLIENT` for one statement.
|
|
278
|
+
QUERY_USE_STORAGE_API_DISABLED_CLIENT = "bigquery.query.use_storage_api_disabled_client"
|
|
279
|
+
|
|
280
|
+
#: How the query writes to an existing destination table: a `WriteDisposition` value.
|
|
281
|
+
QUERY_WRITE_DISPOSITION = "bigquery.query.write_disposition"
|
|
282
|
+
|
|
283
|
+
#: Standard ADBC bulk-ingest mode: whether the target table is created, appended to,
|
|
284
|
+
#: replaced, or created and appended to.
|
|
285
|
+
INGEST_MODE = "adbc.ingest.mode"
|
|
286
|
+
|
|
287
|
+
#: Standard ADBC bulk-ingest target table name.
|
|
288
|
+
INGEST_TARGET_TABLE = "adbc.ingest.target_table"
|
|
289
|
+
|
|
290
|
+
#: Standard ADBC bulk-ingest target catalog: the BigQuery project.
|
|
291
|
+
INGEST_TARGET_CATALOG = "adbc.ingest.target_catalog"
|
|
292
|
+
|
|
293
|
+
#: Standard ADBC bulk-ingest target schema: the BigQuery dataset.
|
|
294
|
+
INGEST_TARGET_DB_SCHEMA = "adbc.ingest.target_db_schema"
|
|
295
|
+
|
|
296
|
+
#: Standard ADBC boolean string. Only `false` is supported: bulk ingest writes into a named
|
|
297
|
+
#: table, never a temporary one.
|
|
298
|
+
INGEST_TEMPORARY = "adbc.ingest.temporary"
|
|
299
|
+
|
|
300
|
+
#: Standard ADBC boolean string. Only `false` is supported: execution returns all partitions
|
|
301
|
+
#: together.
|
|
302
|
+
INCREMENTAL = "adbc.statement.exec.incremental"
|
|
303
|
+
|
|
304
|
+
#: Read-only double: processed bytes reported at query response boundaries. Read with
|
|
305
|
+
#: `get_option_float(member.value)`.
|
|
306
|
+
PROGRESS = "adbc.statement.exec.progress"
|
|
307
|
+
|
|
308
|
+
#: Read-only double: final processed bytes, or `0.0` while unknown. Read with
|
|
309
|
+
#: `get_option_float(member.value)`.
|
|
310
|
+
MAX_PROGRESS = "adbc.statement.exec.max_progress"
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
class ParameterMode(enum.StrEnum):
|
|
314
|
+
"""BigQuery query parameter binding modes."""
|
|
315
|
+
|
|
316
|
+
#: Send bound parameters in field order, for SQL that spells its placeholders `?`. The
|
|
317
|
+
#: default.
|
|
318
|
+
POSITIONAL = "positional"
|
|
319
|
+
|
|
320
|
+
#: Send each bound parameter under the name of the field it came from, for SQL that spells
|
|
321
|
+
#: its placeholders `@name`.
|
|
322
|
+
NAMED = "named"
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
class BulkIngestMethod(enum.StrEnum):
|
|
326
|
+
"""Supported BigQuery bulk-ingest implementations."""
|
|
327
|
+
|
|
328
|
+
#: Append rows through the BigQuery Storage Write API. The default, and the only implemented
|
|
329
|
+
#: method.
|
|
330
|
+
STORAGE_WRITE = "storage_write"
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class AuthenticationType(enum.StrEnum):
|
|
334
|
+
"""Supported Google Cloud authentication modes."""
|
|
335
|
+
|
|
336
|
+
#: Google Cloud Application Default Credentials, under the Go driver's `auth_bigquery`
|
|
337
|
+
#: spelling. What an unconfigured database uses.
|
|
338
|
+
DEFAULT = "auth_bigquery"
|
|
339
|
+
|
|
340
|
+
#: Google Cloud Application Default Credentials, under the `app_default_credentials`
|
|
341
|
+
#: spelling. The same code path as `DEFAULT`.
|
|
342
|
+
APPLICATION_DEFAULT = "app_default_credentials"
|
|
343
|
+
|
|
344
|
+
#: A Google Cloud JSON credential document read from the file path in
|
|
345
|
+
#: `DatabaseOptions.AUTHENTICATION_CREDENTIALS`.
|
|
346
|
+
JSON_CREDENTIAL_FILE = "json_credential_file"
|
|
347
|
+
|
|
348
|
+
#: A Google Cloud JSON credential document passed inline in
|
|
349
|
+
#: `DatabaseOptions.AUTHENTICATION_CREDENTIALS`.
|
|
350
|
+
JSON_CREDENTIAL_STRING = "json_credential_string"
|
|
351
|
+
|
|
352
|
+
#: An OAuth client ID, client secret and refresh token, which the driver redeems for access
|
|
353
|
+
#: tokens.
|
|
354
|
+
USER_AUTHENTICATION = "user_authentication"
|
|
355
|
+
|
|
356
|
+
#: Workload Identity Federation using an OAuth identity-provider token request, configured
|
|
357
|
+
#: with the `AUTHENTICATION_EXTERNAL_ACCOUNT_*` options.
|
|
358
|
+
EXTERNAL_ACCOUNT = "external_account"
|
|
359
|
+
|
|
360
|
+
#: A caller-supplied short-lived OAuth access token, used as-is. The driver never refreshes
|
|
361
|
+
#: it, so requests fail once it expires.
|
|
362
|
+
TEMPORARY_ACCESS_TOKEN = "temporary_access_token"
|
|
363
|
+
|
|
364
|
+
#: No credentials at all: requests carry no token. For emulators and for offline tests, and
|
|
365
|
+
#: incompatible with quota project and impersonation.
|
|
366
|
+
ANONYMOUS = "anonymous"
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
class CredentialsType(enum.StrEnum):
|
|
370
|
+
"""Supported Google Cloud JSON credential document types."""
|
|
371
|
+
|
|
372
|
+
#: A service-account key document.
|
|
373
|
+
SERVICE_ACCOUNT = "service_account"
|
|
374
|
+
|
|
375
|
+
#: A user credential document, as `gcloud auth application-default login` writes.
|
|
376
|
+
AUTHORIZED_USER = "authorized_user"
|
|
377
|
+
|
|
378
|
+
#: A service-account impersonation document, naming a source credential and a target
|
|
379
|
+
#: principal.
|
|
380
|
+
IMPERSONATED_SERVICE_ACCOUNT = "impersonated_service_account"
|
|
381
|
+
|
|
382
|
+
#: A Workload Identity Federation external-account document.
|
|
383
|
+
EXTERNAL_ACCOUNT = "external_account"
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
class QueryPriority(enum.StrEnum):
|
|
387
|
+
"""BigQuery query scheduling priorities."""
|
|
388
|
+
|
|
389
|
+
#: Queue the query until BigQuery has idle resources for it, outside the concurrent-rate
|
|
390
|
+
#: limit interactive queries share.
|
|
391
|
+
BATCH = "BATCH"
|
|
392
|
+
|
|
393
|
+
#: Run the query as soon as possible. The default.
|
|
394
|
+
INTERACTIVE = "INTERACTIVE"
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
class CreateDisposition(enum.StrEnum):
|
|
398
|
+
"""BigQuery destination-table creation behavior."""
|
|
399
|
+
|
|
400
|
+
#: Create the destination table if it does not exist. The default.
|
|
401
|
+
IF_NEEDED = "CREATE_IF_NEEDED"
|
|
402
|
+
|
|
403
|
+
#: Require the destination table to exist already, failing the job if it does not.
|
|
404
|
+
NEVER = "CREATE_NEVER"
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
class WriteDisposition(enum.StrEnum):
|
|
408
|
+
"""BigQuery destination-table write behavior."""
|
|
409
|
+
|
|
410
|
+
#: Append the rows to the destination table's existing data.
|
|
411
|
+
APPEND = "WRITE_APPEND"
|
|
412
|
+
|
|
413
|
+
#: Replace the destination table's existing data with the rows written.
|
|
414
|
+
TRUNCATE = "WRITE_TRUNCATE"
|
|
415
|
+
|
|
416
|
+
#: Fail the job unless the destination table is empty. The default.
|
|
417
|
+
EMPTY = "WRITE_EMPTY"
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
__all__ = [
|
|
421
|
+
"AuthenticationType",
|
|
422
|
+
"BulkIngestMethod",
|
|
423
|
+
"ConnectionOptions",
|
|
424
|
+
"CreateDisposition",
|
|
425
|
+
"CredentialsType",
|
|
426
|
+
"DatabaseOptions",
|
|
427
|
+
"ParameterMode",
|
|
428
|
+
"QueryPriority",
|
|
429
|
+
"StatementOptions",
|
|
430
|
+
"WriteDisposition",
|
|
431
|
+
]
|
|
Binary file
|