feat: Add BigQuery analyze_contribution tool

This change introduces a new `analyze_contribution` function in `query_tool.py` which uses BigQuery ML's `CREATE MODEL` with `CONTRIBUTION_ANALYSIS` type and `ML.GET_INSIGHTS` to analyze the contribution of different dimensions to a given metric. The new function is also added to the `bigquery_toolset`.

PiperOrigin-RevId: 815849281
This commit is contained in:
Haoming Chen
2025-10-06 12:59:09 -07:00
committed by Copybara-Service
parent 5c6cdcd197
commit 4bb089d386
4 changed files with 333 additions and 2 deletions
@@ -41,7 +41,7 @@ async def test_bigquery_toolset_tools_default():
tools = await toolset.get_tools()
assert tools is not None
assert len(tools) == 7
assert len(tools) == 8
assert all([isinstance(tool, GoogleTool) for tool in tools])
expected_tool_names = set([
@@ -52,6 +52,7 @@ async def test_bigquery_toolset_tools_default():
"execute_sql",
"ask_data_insights",
"forecast",
"analyze_contribution",
])
actual_tool_names = set([tool.name for tool in tools])
assert actual_tool_names == expected_tool_names