feat: Add get_job_info tool to BigQuery toolset

This CL introduces a new tool, get_job_info, to the BigQuery toolset. This tool allows retrieving metadata about a BigQuery job, such as slot usage, job configuration, statistics, and job status.

Closes #2928

Co-authored-by: Dongyu Jia <dongyuj@google.com>
PiperOrigin-RevId: 825762399
This commit is contained in:
Dongyu Jia
2025-10-29 16:46:31 -07:00
committed by Copybara-Service
parent 72a8d8d85b
commit 64294572c1
5 changed files with 330 additions and 1 deletions
@@ -136,6 +136,36 @@ def test_get_table_info_no_default_auth(mock_default_auth, mock_get_table):
mock_default_auth.assert_not_called()
@mock.patch.dict(os.environ, {}, clear=True)
@mock.patch("google.cloud.bigquery.Client.get_job", autospec=True)
@mock.patch("google.auth.default", autospec=True)
def test_get_job_info_no_default_auth(mock_default_auth, mock_get_job):
"""Test get_job_info tool invocation involves no default auth."""
mock_credentials = mock.create_autospec(Credentials, instance=True)
tool_settings = BigQueryToolConfig()
# Simulate the behavior of default auth - on purpose throw exception when
# the default auth is called
mock_default_auth.side_effect = DefaultCredentialsError(
"Your default credentials were not found"
)
mock_get_job.return_value = mock.create_autospec(
bigquery.QueryJob, instance=True
)
result = metadata_tool.get_job_info(
"my_project_id",
"my_job_id",
mock_credentials,
tool_settings,
)
assert result != {
"status": "ERROR",
"error_details": "Your default credentials were not found",
}
mock_default_auth.assert_not_called()
@mock.patch(
"google.adk.tools.bigquery.client.get_bigquery_client", autospec=True
)
@@ -41,7 +41,7 @@ async def test_bigquery_toolset_tools_default():
tools = await toolset.get_tools()
assert tools is not None
assert len(tools) == 9
assert len(tools) == 10
assert all([isinstance(tool, GoogleTool) for tool in tools])
expected_tool_names = set([
@@ -49,6 +49,7 @@ async def test_bigquery_toolset_tools_default():
"get_dataset_info",
"list_table_ids",
"get_table_info",
"get_job_info",
"execute_sql",
"ask_data_insights",
"forecast",