Skip to content

chore(bigquery): refactor conversational analytics handlers and fix tests#2567

Merged
duwenxin99 merged 2 commits intogoogleapis:mainfrom
Genesis929:fix-ca-tool-response
Feb 26, 2026
Merged

chore(bigquery): refactor conversational analytics handlers and fix tests#2567
duwenxin99 merged 2 commits intogoogleapis:mainfrom
Genesis929:fix-ca-tool-response

Conversation

@Genesis929
Copy link
Copy Markdown
Contributor

@Genesis929 Genesis929 commented Feb 26, 2026

Description

BigQuery Conversational Analytics tests have been failing, and it appears the cause is a recent change in the API's response format and streaming behavior. This PR refactors the handlers to aggregate response fields correctly.

PR Checklist

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

@Genesis929 Genesis929 changed the title chore(bigquery): refactor conversational analytics handlers and fix t… chore(bigquery): refactor conversational analytics handlers and fix tests Feb 26, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Genesis929, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the BigQuery conversational analytics handlers to enhance the structure and content of the responses. The changes enable handlers to return a richer set of information by accumulating results in a map, and improve the conversation flow by ensuring that only the most current data retrieval results are maintained in the message history. This leads to more informative and streamlined interactions with the BigQuery tool.

Highlights

  • Refactored Response Handling: The handleSchemaResponse and handleDataResponse functions were refactored to accumulate all relevant information into a single map before returning, allowing for more comprehensive responses that can include multiple data points like questions, schema, SQL, and retrieved data.
  • Improved Message Appending Logic: The appendMessage function was updated to intelligently manage 'Data Retrieved' entries. It now ensures that only the most recent 'Data Retrieved' message is kept in the conversation history, while preserving other metadata like generated SQL or retrieval queries from previous steps.
  • Updated Integration Tests: Integration tests were adjusted to accommodate the new response structures. Specifically, the regex for dataInsightsWant was made more flexible to account for optional 'Schema Resolved' and 'Retrieval Query' fields, and a test case's expected output was updated to use this new regex.
Changelog
  • internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go
    • Refactored handleSchemaResponse to initialize a result map and add query or schema information to it before returning.
    • Refactored handleDataResponse to initialize a result map and add query, generated SQL, or data retrieval information to it before returning.
    • Modified appendMessage to iterate and remove older 'Data Retrieved' entries when a new one is added, ensuring only the latest data result is present.
  • tests/bigquery/bigquery_integration_test.go
    • Updated dataInsightsWant regular expression to make 'Schema Resolved' and 'Retrieval Query' optional components.
    • Changed the expected want value in a specific test case to use the more flexible dataInsightsWant regex.
Activity
  • The pull request description includes a standard PR checklist, none of which appear to be checked off yet.
  • The description indicates a chore type change related to BigQuery, focusing on refactoring handlers and fixing tests.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the conversational analytics handlers in bigqueryconversationalanalytics.go to correctly aggregate different parts of a response into a single message, fixing a bug where some information could be lost. The logic for appending messages is also improved to correctly handle Data Retrieved messages, preventing duplicates while preserving other contextual data. The integration tests have been updated to reflect these changes, with more accurate assertions for the expected output. The changes are well-implemented and improve the correctness and robustness of the conversational analytics tool.

@Genesis929 Genesis929 marked this pull request as ready for review February 26, 2026 06:31
@Genesis929 Genesis929 requested a review from a team as a code owner February 26, 2026 06:31
@averikitsch averikitsch added the tests: run Label to trigger Github Action tests. label Feb 26, 2026
@github-actions github-actions bot removed the tests: run Label to trigger Github Action tests. label Feb 26, 2026
@averikitsch
Copy link
Copy Markdown
Contributor

/gcbrun

@duwenxin99
Copy link
Copy Markdown
Contributor

@Genesis929 Seems like there's still one test failure:

=== RUN   TestBigQueryToolEndpoints/Invoke_my-client-auth-conversational-analytics-tool_with_auth_token
    bigquery_integration_test.go:2454: Request timed out (attempt 1/3), retrying...
    bigquery_integration_test.go:2454: Request timed out (attempt 2/3), retrying...
    bigquery_integration_test.go:2454: Request timed out (attempt 3/3), retrying...
    bigquery_integration_test.go:2469: Request failed after 3 retries: Post "http://127.0.0.1:5000/api/tool/my-client-auth-conversational-analytics-tool/invoke": context deadline exceeded

@duwenxin99 duwenxin99 enabled auto-merge (squash) February 26, 2026 22:05
@duwenxin99 duwenxin99 merged commit 664f72c into googleapis:main Feb 26, 2026
16 of 17 checks passed
AjmeraParth132 pushed a commit to AjmeraParth132/genai-toolbox that referenced this pull request Mar 2, 2026
…ests (googleapis#2567)

## Description
BigQuery Conversational Analytics tests have been failing, and it
appears the cause is a recent change in the API's response format and
streaming behavior. This PR refactors the handlers to aggregate response
fields correctly.

## PR Checklist

> Thank you for opening a Pull Request! Before submitting your PR, there
are a
> few things you can do to make sure it goes smoothly:

- [ ] Make sure you reviewed

[CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md)
- [ ] Make sure to open an issue as a

[bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose)
  before writing your code! That way we can discuss the change, evaluate
  designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)
- [ ] Make sure to add `!` if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

Co-authored-by: Averi Kitsch <akitsch@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants