google-adk 1.2.0__py3-none-any.whl → 1.4.0__py3-none-any.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.
- google/adk/a2a/__init__.py +13 -0
- google/adk/a2a/converters/__init__.py +13 -0
- google/adk/a2a/converters/part_converter.py +166 -0
- google/adk/agents/invocation_context.py +2 -0
- google/adk/agents/llm_agent.py +1 -6
- google/adk/agents/run_config.py +11 -0
- google/adk/auth/auth_credential.py +5 -0
- google/adk/auth/auth_handler.py +22 -96
- google/adk/auth/auth_preprocessor.py +3 -3
- google/adk/auth/auth_tool.py +46 -0
- google/adk/auth/credential_manager.py +265 -0
- google/adk/auth/credential_service/__init__.py +13 -0
- google/adk/auth/credential_service/base_credential_service.py +75 -0
- google/adk/auth/credential_service/in_memory_credential_service.py +64 -0
- google/adk/auth/exchanger/__init__.py +23 -0
- google/adk/auth/exchanger/base_credential_exchanger.py +57 -0
- google/adk/auth/exchanger/credential_exchanger_registry.py +58 -0
- google/adk/auth/exchanger/oauth2_credential_exchanger.py +104 -0
- google/adk/auth/exchanger/service_account_credential_exchanger.py +104 -0
- google/adk/auth/oauth2_credential_util.py +107 -0
- google/adk/auth/refresher/__init__.py +21 -0
- google/adk/auth/refresher/base_credential_refresher.py +74 -0
- google/adk/auth/refresher/credential_refresher_registry.py +59 -0
- google/adk/auth/refresher/oauth2_credential_refresher.py +154 -0
- google/adk/cli/agent_graph.py +34 -32
- google/adk/cli/browser/index.html +2 -2
- google/adk/cli/browser/main-JAAWEV7F.js +92 -0
- google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
- google/adk/cli/cli.py +10 -0
- google/adk/cli/cli_deploy.py +80 -21
- google/adk/cli/cli_tools_click.py +132 -61
- google/adk/cli/fast_api.py +46 -41
- google/adk/cli/utils/agent_loader.py +15 -2
- google/adk/cli/utils/evals.py +4 -2
- google/adk/code_executors/container_code_executor.py +10 -6
- google/adk/code_executors/vertex_ai_code_executor.py +8 -2
- google/adk/evaluation/_eval_set_results_manager_utils.py +44 -0
- google/adk/evaluation/_eval_sets_manager_utils.py +108 -0
- google/adk/evaluation/eval_metrics.py +0 -5
- google/adk/evaluation/eval_result.py +12 -7
- google/adk/evaluation/eval_set_results_manager.py +6 -1
- google/adk/evaluation/gcs_eval_set_results_manager.py +121 -0
- google/adk/evaluation/gcs_eval_sets_manager.py +196 -0
- google/adk/evaluation/local_eval_set_results_manager.py +6 -18
- google/adk/evaluation/local_eval_sets_manager.py +27 -78
- google/adk/evaluation/response_evaluator.py +5 -5
- google/adk/evaluation/trajectory_evaluator.py +9 -6
- google/adk/flows/llm_flows/basic.py +9 -0
- google/adk/models/anthropic_llm.py +1 -1
- google/adk/models/gemini_llm_connection.py +2 -0
- google/adk/models/google_llm.py +57 -16
- google/adk/models/lite_llm.py +2 -1
- google/adk/platform/__init__.py +13 -0
- google/adk/platform/internal/__init__.py +15 -0
- google/adk/platform/internal/thread.py +30 -0
- google/adk/platform/thread.py +31 -0
- google/adk/runners.py +8 -2
- google/adk/sessions/in_memory_session_service.py +12 -1
- google/adk/sessions/vertex_ai_session_service.py +71 -50
- google/adk/tools/__init__.py +2 -0
- google/adk/tools/_automatic_function_calling_util.py +1 -0
- google/adk/tools/_forwarding_artifact_service.py +96 -0
- google/adk/tools/_function_parameter_parse_util.py +1 -0
- google/adk/tools/agent_tool.py +5 -39
- google/adk/tools/application_integration_tool/integration_connector_tool.py +2 -2
- google/adk/tools/authenticated_function_tool.py +107 -0
- google/adk/tools/base_authenticated_tool.py +107 -0
- google/adk/tools/bigquery/bigquery_credentials.py +6 -4
- google/adk/tools/bigquery/bigquery_tool.py +22 -9
- google/adk/tools/bigquery/bigquery_toolset.py +9 -3
- google/adk/tools/bigquery/client.py +7 -3
- google/adk/tools/bigquery/config.py +46 -0
- google/adk/tools/bigquery/metadata_tool.py +114 -91
- google/adk/tools/bigquery/query_tool.py +141 -23
- google/adk/tools/google_api_tool/googleapi_to_openapi_converter.py +7 -4
- google/adk/tools/google_search_tool.py +0 -1
- google/adk/tools/mcp_tool/__init__.py +6 -0
- google/adk/tools/mcp_tool/mcp_session_manager.py +271 -149
- google/adk/tools/mcp_tool/mcp_tool.py +79 -22
- google/adk/tools/mcp_tool/mcp_toolset.py +32 -29
- google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +3 -3
- google/adk/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.py +56 -33
- google/adk/tools/retrieval/files_retrieval.py +7 -1
- google/adk/tools/url_context_tool.py +61 -0
- google/adk/tools/vertex_ai_search_tool.py +13 -2
- google/adk/utils/feature_decorator.py +175 -0
- google/adk/version.py +2 -2
- {google_adk-1.2.0.dist-info → google_adk-1.4.0.dist-info}/METADATA +10 -1
- {google_adk-1.2.0.dist-info → google_adk-1.4.0.dist-info}/RECORD +92 -61
- google/adk/cli/browser/main-CS5OLUMF.js +0 -91
- google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -17
- {google_adk-1.2.0.dist-info → google_adk-1.4.0.dist-info}/WHEEL +0 -0
- {google_adk-1.2.0.dist-info → google_adk-1.4.0.dist-info}/entry_points.txt +0 -0
- {google_adk-1.2.0.dist-info → google_adk-1.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -27,16 +27,18 @@ from google.oauth2.credentials import Credentials
|
|
27
27
|
from pydantic import BaseModel
|
28
28
|
from pydantic import model_validator
|
29
29
|
|
30
|
-
from ...auth import
|
31
|
-
from ...auth import
|
32
|
-
from ...auth import
|
33
|
-
from ...auth import
|
30
|
+
from ...auth.auth_credential import AuthCredential
|
31
|
+
from ...auth.auth_credential import AuthCredentialTypes
|
32
|
+
from ...auth.auth_credential import OAuth2Auth
|
33
|
+
from ...auth.auth_tool import AuthConfig
|
34
|
+
from ...utils.feature_decorator import experimental
|
34
35
|
from ..tool_context import ToolContext
|
35
36
|
|
36
37
|
BIGQUERY_TOKEN_CACHE_KEY = "bigquery_token_cache"
|
37
38
|
BIGQUERY_DEFAULT_SCOPE = ["https://www.googleapis.com/auth/bigquery"]
|
38
39
|
|
39
40
|
|
41
|
+
@experimental
|
40
42
|
class BigQueryCredentialsConfig(BaseModel):
|
41
43
|
"""Configuration for Google API tools. (Experimental)"""
|
42
44
|
|
@@ -12,6 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
from __future__ import annotations
|
15
16
|
|
16
17
|
import inspect
|
17
18
|
from typing import Any
|
@@ -21,12 +22,15 @@ from typing import Optional
|
|
21
22
|
from google.oauth2.credentials import Credentials
|
22
23
|
from typing_extensions import override
|
23
24
|
|
25
|
+
from ...utils.feature_decorator import experimental
|
24
26
|
from ..function_tool import FunctionTool
|
25
27
|
from ..tool_context import ToolContext
|
26
28
|
from .bigquery_credentials import BigQueryCredentialsConfig
|
27
29
|
from .bigquery_credentials import BigQueryCredentialsManager
|
30
|
+
from .config import BigQueryToolConfig
|
28
31
|
|
29
32
|
|
33
|
+
@experimental
|
30
34
|
class BigQueryTool(FunctionTool):
|
31
35
|
"""GoogleApiTool class for tools that call Google APIs.
|
32
36
|
|
@@ -41,21 +45,27 @@ class BigQueryTool(FunctionTool):
|
|
41
45
|
def __init__(
|
42
46
|
self,
|
43
47
|
func: Callable[..., Any],
|
44
|
-
|
48
|
+
*,
|
49
|
+
credentials_config: Optional[BigQueryCredentialsConfig] = None,
|
50
|
+
bigquery_tool_config: Optional[BigQueryToolConfig] = None,
|
45
51
|
):
|
46
52
|
"""Initialize the Google API tool.
|
47
53
|
|
48
54
|
Args:
|
49
55
|
func: callable that impelments the tool's logic, can accept one
|
50
56
|
'credential" parameter
|
51
|
-
|
52
|
-
hanlde the auth logic
|
57
|
+
credentials_config: credentials config used to call Google API. If None,
|
58
|
+
then we don't hanlde the auth logic
|
53
59
|
"""
|
54
60
|
super().__init__(func=func)
|
55
61
|
self._ignore_params.append("credentials")
|
56
|
-
self.
|
57
|
-
|
62
|
+
self._ignore_params.append("config")
|
63
|
+
self._credentials_manager = (
|
64
|
+
BigQueryCredentialsManager(credentials_config)
|
65
|
+
if credentials_config
|
66
|
+
else None
|
58
67
|
)
|
68
|
+
self._tool_config = bigquery_tool_config
|
59
69
|
|
60
70
|
@override
|
61
71
|
async def run_async(
|
@@ -69,12 +79,12 @@ class BigQueryTool(FunctionTool):
|
|
69
79
|
try:
|
70
80
|
# Get valid credentials
|
71
81
|
credentials = (
|
72
|
-
await self.
|
73
|
-
if self.
|
82
|
+
await self._credentials_manager.get_valid_credentials(tool_context)
|
83
|
+
if self._credentials_manager
|
74
84
|
else None
|
75
85
|
)
|
76
86
|
|
77
|
-
if credentials is None and self.
|
87
|
+
if credentials is None and self._credentials_manager:
|
78
88
|
# OAuth flow in progress
|
79
89
|
return (
|
80
90
|
"User authorization is required to access Google services for"
|
@@ -84,7 +94,7 @@ class BigQueryTool(FunctionTool):
|
|
84
94
|
# Execute the tool's specific logic with valid credentials
|
85
95
|
|
86
96
|
return await self._run_async_with_credential(
|
87
|
-
credentials, args, tool_context
|
97
|
+
credentials, self._tool_config, args, tool_context
|
88
98
|
)
|
89
99
|
|
90
100
|
except Exception as ex:
|
@@ -96,6 +106,7 @@ class BigQueryTool(FunctionTool):
|
|
96
106
|
async def _run_async_with_credential(
|
97
107
|
self,
|
98
108
|
credentials: Credentials,
|
109
|
+
tool_config: BigQueryToolConfig,
|
99
110
|
args: dict[str, Any],
|
100
111
|
tool_context: ToolContext,
|
101
112
|
) -> Any:
|
@@ -113,4 +124,6 @@ class BigQueryTool(FunctionTool):
|
|
113
124
|
signature = inspect.signature(self.func)
|
114
125
|
if "credentials" in signature.parameters:
|
115
126
|
args_to_call["credentials"] = credentials
|
127
|
+
if "config" in signature.parameters:
|
128
|
+
args_to_call["config"] = tool_config
|
116
129
|
return await super().run_async(args=args_to_call, tool_context=tool_context)
|
@@ -26,10 +26,13 @@ from . import query_tool
|
|
26
26
|
from ...tools.base_tool import BaseTool
|
27
27
|
from ...tools.base_toolset import BaseToolset
|
28
28
|
from ...tools.base_toolset import ToolPredicate
|
29
|
+
from ...utils.feature_decorator import experimental
|
29
30
|
from .bigquery_credentials import BigQueryCredentialsConfig
|
30
31
|
from .bigquery_tool import BigQueryTool
|
32
|
+
from .config import BigQueryToolConfig
|
31
33
|
|
32
34
|
|
35
|
+
@experimental
|
33
36
|
class BigQueryToolset(BaseToolset):
|
34
37
|
"""BigQuery Toolset contains tools for interacting with BigQuery data and metadata."""
|
35
38
|
|
@@ -38,9 +41,11 @@ class BigQueryToolset(BaseToolset):
|
|
38
41
|
*,
|
39
42
|
tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
|
40
43
|
credentials_config: Optional[BigQueryCredentialsConfig] = None,
|
44
|
+
bigquery_tool_config: Optional[BigQueryToolConfig] = None,
|
41
45
|
):
|
42
|
-
self._credentials_config = credentials_config
|
43
46
|
self.tool_filter = tool_filter
|
47
|
+
self._credentials_config = credentials_config
|
48
|
+
self._tool_config = bigquery_tool_config
|
44
49
|
|
45
50
|
def _is_tool_selected(
|
46
51
|
self, tool: BaseTool, readonly_context: ReadonlyContext
|
@@ -64,14 +69,15 @@ class BigQueryToolset(BaseToolset):
|
|
64
69
|
all_tools = [
|
65
70
|
BigQueryTool(
|
66
71
|
func=func,
|
67
|
-
|
72
|
+
credentials_config=self._credentials_config,
|
73
|
+
bigquery_tool_config=self._tool_config,
|
68
74
|
)
|
69
75
|
for func in [
|
70
76
|
metadata_tool.get_dataset_info,
|
71
77
|
metadata_tool.get_table_info,
|
72
78
|
metadata_tool.list_dataset_ids,
|
73
79
|
metadata_tool.list_table_ids,
|
74
|
-
query_tool.
|
80
|
+
query_tool.get_execute_sql(self._tool_config),
|
75
81
|
]
|
76
82
|
]
|
77
83
|
|
@@ -18,16 +18,20 @@ import google.api_core.client_info
|
|
18
18
|
from google.cloud import bigquery
|
19
19
|
from google.oauth2.credentials import Credentials
|
20
20
|
|
21
|
-
|
21
|
+
from ... import version
|
22
22
|
|
23
|
+
USER_AGENT = f"adk-bigquery-tool google-adk/{version.__version__}"
|
23
24
|
|
24
|
-
|
25
|
+
|
26
|
+
def get_bigquery_client(
|
27
|
+
*, project: str, credentials: Credentials
|
28
|
+
) -> bigquery.Client:
|
25
29
|
"""Get a BigQuery client."""
|
26
30
|
|
27
31
|
client_info = google.api_core.client_info.ClientInfo(user_agent=USER_AGENT)
|
28
32
|
|
29
33
|
bigquery_client = bigquery.Client(
|
30
|
-
credentials=credentials, client_info=client_info
|
34
|
+
project=project, credentials=credentials, client_info=client_info
|
31
35
|
)
|
32
36
|
|
33
37
|
return bigquery_client
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright 2025 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
from __future__ import annotations
|
16
|
+
|
17
|
+
from enum import Enum
|
18
|
+
|
19
|
+
from pydantic import BaseModel
|
20
|
+
|
21
|
+
from ...utils.feature_decorator import experimental
|
22
|
+
|
23
|
+
|
24
|
+
class WriteMode(Enum):
|
25
|
+
"""Write mode indicating what levels of write operations are allowed in BigQuery."""
|
26
|
+
|
27
|
+
BLOCKED = 'blocked'
|
28
|
+
"""No write operations are allowed.
|
29
|
+
|
30
|
+
This mode implies that only read (i.e. SELECT query) operations are allowed.
|
31
|
+
"""
|
32
|
+
|
33
|
+
ALLOWED = 'allowed'
|
34
|
+
"""All write operations are allowed."""
|
35
|
+
|
36
|
+
|
37
|
+
@experimental('Config defaults may have breaking change in the future.')
|
38
|
+
class BigQueryToolConfig(BaseModel):
|
39
|
+
"""Configuration for BigQuery tools."""
|
40
|
+
|
41
|
+
write_mode: WriteMode = WriteMode.BLOCKED
|
42
|
+
"""Write mode for BigQuery tools.
|
43
|
+
|
44
|
+
By default, the tool will allow only read operations. This behaviour may
|
45
|
+
change in future versions.
|
46
|
+
"""
|
@@ -15,7 +15,7 @@
|
|
15
15
|
from google.cloud import bigquery
|
16
16
|
from google.oauth2.credentials import Credentials
|
17
17
|
|
18
|
-
from
|
18
|
+
from . import client
|
19
19
|
|
20
20
|
|
21
21
|
def list_dataset_ids(project_id: str, credentials: Credentials) -> list[str]:
|
@@ -42,7 +42,9 @@ def list_dataset_ids(project_id: str, credentials: Credentials) -> list[str]:
|
|
42
42
|
'bbc_news']
|
43
43
|
"""
|
44
44
|
try:
|
45
|
-
bq_client = client.get_bigquery_client(
|
45
|
+
bq_client = client.get_bigquery_client(
|
46
|
+
project=project_id, credentials=credentials
|
47
|
+
)
|
46
48
|
|
47
49
|
datasets = []
|
48
50
|
for dataset in bq_client.list_datasets(project_id):
|
@@ -69,40 +71,46 @@ def get_dataset_info(
|
|
69
71
|
dict: Dictionary representing the properties of the dataset.
|
70
72
|
|
71
73
|
Examples:
|
72
|
-
>>> get_dataset_info("bigquery-public-data", "
|
74
|
+
>>> get_dataset_info("bigquery-public-data", "cdc_places")
|
73
75
|
{
|
74
76
|
"kind": "bigquery#dataset",
|
75
|
-
"etag": "
|
76
|
-
"id": "bigquery-public-data:
|
77
|
-
"selfLink":
|
78
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/bigquery-public-data/datasets/ml_datasets",
|
77
|
+
"etag": "fz9BaiXKgbGi53EpI2rJug==",
|
78
|
+
"id": "bigquery-public-data:cdc_places",
|
79
|
+
"selfLink": "https://content-bigquery.googleapis.com/bigquery/v2/projects/bigquery-public-data/datasets/cdc_places",
|
79
80
|
"datasetReference": {
|
80
|
-
|
81
|
-
|
81
|
+
"datasetId": "cdc_places",
|
82
|
+
"projectId": "bigquery-public-data"
|
82
83
|
},
|
84
|
+
"description": "Local Data for Better Health, County Data",
|
83
85
|
"access": [
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
86
|
+
{
|
87
|
+
"role": "WRITER",
|
88
|
+
"specialGroup": "projectWriters"
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"role": "OWNER",
|
92
|
+
"specialGroup": "projectOwners"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"role": "OWNER",
|
96
|
+
"userByEmail": "some-redacted-email@bigquery-public-data.iam.gserviceaccount.com"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"role": "READER",
|
100
|
+
"specialGroup": "projectReaders"
|
101
|
+
}
|
96
102
|
],
|
97
|
-
"creationTime": "
|
98
|
-
"lastModifiedTime": "
|
103
|
+
"creationTime": "1640891845643",
|
104
|
+
"lastModifiedTime": "1640891845643",
|
99
105
|
"location": "US",
|
100
106
|
"type": "DEFAULT",
|
101
107
|
"maxTimeTravelHours": "168"
|
102
108
|
}
|
103
109
|
"""
|
104
110
|
try:
|
105
|
-
bq_client = client.get_bigquery_client(
|
111
|
+
bq_client = client.get_bigquery_client(
|
112
|
+
project=project_id, credentials=credentials
|
113
|
+
)
|
106
114
|
dataset = bq_client.get_dataset(
|
107
115
|
bigquery.DatasetReference(project_id, dataset_id)
|
108
116
|
)
|
@@ -128,16 +136,14 @@ def list_table_ids(
|
|
128
136
|
list[str]: List of the tables ids present in the dataset.
|
129
137
|
|
130
138
|
Examples:
|
131
|
-
>>> list_table_ids("bigquery-public-data", "
|
132
|
-
['
|
133
|
-
'
|
134
|
-
'holidays_and_events_for_forecasting',
|
135
|
-
'iris',
|
136
|
-
'penguins',
|
137
|
-
'ulb_fraud_detection']
|
139
|
+
>>> list_table_ids("bigquery-public-data", "cdc_places")
|
140
|
+
['chronic_disease_indicators',
|
141
|
+
'local_data_for_better_health_county_data']
|
138
142
|
"""
|
139
143
|
try:
|
140
|
-
bq_client = client.get_bigquery_client(
|
144
|
+
bq_client = client.get_bigquery_client(
|
145
|
+
project=project_id, credentials=credentials
|
146
|
+
)
|
141
147
|
|
142
148
|
tables = []
|
143
149
|
for table in bq_client.list_tables(
|
@@ -167,76 +173,93 @@ def get_table_info(
|
|
167
173
|
dict: Dictionary representing the properties of the table.
|
168
174
|
|
169
175
|
Examples:
|
170
|
-
>>> get_table_info("bigquery-public-data", "
|
176
|
+
>>> get_table_info("bigquery-public-data", "cdc_places", "local_data_for_better_health_county_data")
|
171
177
|
{
|
172
178
|
"kind": "bigquery#table",
|
173
|
-
"etag": "
|
174
|
-
"id": "bigquery-public-data:
|
175
|
-
"selfLink":
|
176
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/bigquery-public-data/datasets/ml_datasets/tables/penguins",
|
179
|
+
"etag": "wx23aDqmgc39oUSiNuYTAA==",
|
180
|
+
"id": "bigquery-public-data:cdc_places.local_data_for_better_health_county_data",
|
181
|
+
"selfLink": "https://content-bigquery.googleapis.com/bigquery/v2/projects/bigquery-public-data/datasets/cdc_places/tables/local_data_for_better_health_county_data",
|
177
182
|
"tableReference": {
|
178
|
-
|
179
|
-
|
180
|
-
|
183
|
+
"projectId": "bigquery-public-data",
|
184
|
+
"datasetId": "cdc_places",
|
185
|
+
"tableId": "local_data_for_better_health_county_data"
|
181
186
|
},
|
187
|
+
"description": "Local Data for Better Health, County Data",
|
182
188
|
"schema": {
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
189
|
+
"fields": [
|
190
|
+
{
|
191
|
+
"name": "year",
|
192
|
+
"type": "INTEGER",
|
193
|
+
"mode": "NULLABLE"
|
194
|
+
},
|
195
|
+
{
|
196
|
+
"name": "stateabbr",
|
197
|
+
"type": "STRING",
|
198
|
+
"mode": "NULLABLE"
|
199
|
+
},
|
200
|
+
{
|
201
|
+
"name": "statedesc",
|
202
|
+
"type": "STRING",
|
203
|
+
"mode": "NULLABLE"
|
204
|
+
},
|
205
|
+
{
|
206
|
+
"name": "locationname",
|
207
|
+
"type": "STRING",
|
208
|
+
"mode": "NULLABLE"
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"name": "datasource",
|
212
|
+
"type": "STRING",
|
213
|
+
"mode": "NULLABLE"
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"name": "category",
|
217
|
+
"type": "STRING",
|
218
|
+
"mode": "NULLABLE"
|
219
|
+
},
|
220
|
+
{
|
221
|
+
"name": "measure",
|
222
|
+
"type": "STRING",
|
223
|
+
"mode": "NULLABLE"
|
224
|
+
},
|
225
|
+
{
|
226
|
+
"name": "data_value_unit",
|
227
|
+
"type": "STRING",
|
228
|
+
"mode": "NULLABLE"
|
229
|
+
},
|
230
|
+
{
|
231
|
+
"name": "data_value_type",
|
232
|
+
"type": "STRING",
|
233
|
+
"mode": "NULLABLE"
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"name": "data_value",
|
237
|
+
"type": "FLOAT",
|
238
|
+
"mode": "NULLABLE"
|
239
|
+
}
|
240
|
+
]
|
220
241
|
},
|
221
|
-
"numBytes": "
|
222
|
-
"numLongTermBytes": "
|
223
|
-
"numRows": "
|
224
|
-
"creationTime": "
|
225
|
-
"lastModifiedTime": "
|
242
|
+
"numBytes": "234849",
|
243
|
+
"numLongTermBytes": "0",
|
244
|
+
"numRows": "1000",
|
245
|
+
"creationTime": "1640891846119",
|
246
|
+
"lastModifiedTime": "1749427268137",
|
226
247
|
"type": "TABLE",
|
227
248
|
"location": "US",
|
228
|
-
"numTimeTravelPhysicalBytes": "
|
229
|
-
"numTotalLogicalBytes": "
|
230
|
-
"numActiveLogicalBytes": "
|
231
|
-
"numLongTermLogicalBytes": "
|
232
|
-
"numTotalPhysicalBytes": "
|
233
|
-
"numActivePhysicalBytes": "
|
234
|
-
"numLongTermPhysicalBytes": "
|
235
|
-
"numCurrentPhysicalBytes": "
|
249
|
+
"numTimeTravelPhysicalBytes": "285737",
|
250
|
+
"numTotalLogicalBytes": "234849",
|
251
|
+
"numActiveLogicalBytes": "234849",
|
252
|
+
"numLongTermLogicalBytes": "0",
|
253
|
+
"numTotalPhysicalBytes": "326557",
|
254
|
+
"numActivePhysicalBytes": "326557",
|
255
|
+
"numLongTermPhysicalBytes": "0",
|
256
|
+
"numCurrentPhysicalBytes": "40820"
|
236
257
|
}
|
237
258
|
"""
|
238
259
|
try:
|
239
|
-
bq_client = client.get_bigquery_client(
|
260
|
+
bq_client = client.get_bigquery_client(
|
261
|
+
project=project_id, credentials=credentials
|
262
|
+
)
|
240
263
|
return bq_client.get_table(
|
241
264
|
bigquery.TableReference(
|
242
265
|
bigquery.DatasetReference(project_id, dataset_id), table_id
|