Skip to content

fix: reduce conflicts between Spanner and BigQuery graph visualization on Colab#209

Merged
tswast merged 1 commit intomainfrom
colab
Feb 4, 2026
Merged

fix: reduce conflicts between Spanner and BigQuery graph visualization on Colab#209
tswast merged 1 commit intomainfrom
colab

Conversation

@ericfe-google
Copy link
Contributor

…d Spanner. This avoids clashes if the same notebook uses visualizers for both BigQuery graphs and Spanner graphs, which can cause malfunctions in the visualizers.

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 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)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery-magics API. labels Feb 4, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @ericfe-google, 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 resolves a potential naming conflict in Google Colab environments where BigQuery graph visualizers could clash with other visualizers, such as those for Spanner, if they used identical callback endpoint names. By introducing a "bigquery." prefix to the graph visualization callback names, this change ensures that BigQuery-specific visualizer functions are uniquely identified, preventing malfunctions and improving the robustness of interactive notebooks that integrate multiple data visualization tools.

Highlights

  • Colab Callback Naming: Renamed output.register_callback endpoints for graph visualization from generic names (e.g., graph_visualization.Query) to bigquery.graph_visualization.Query and bigquery.graph_visualization.NodeExpansion to prevent naming conflicts.
  • HTML Content Update: Modified the generated HTML content for the graph widget to reflect the new, prefixed callback names, ensuring consistency between registered callbacks and their usage in the frontend.
Changelog
  • bigquery_magics/bigquery.py
    • Updated output.register_callback calls to use bigquery.graph_visualization.Query and bigquery.graph_visualization.NodeExpansion instead of the generic graph_visualization prefix.
    • Applied corresponding string replacements in the generated HTML content to match the new, unique callback names.
Activity
  • No human activity (comments, reviews, etc.) has been provided for this pull request.
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.

…d Spanner. This avoids clashes if the same notebook uses visualizers for both BigQuery graphs and Spanner graphs, which can cause malfunctions in the visualizers.
Copy link

@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 makes the Colab endpoint names for graph visualization unique for BigQuery to avoid clashes with Spanner. The changes correctly update the callback registration and the generated HTML. My review includes one suggestion to improve maintainability by replacing duplicated hardcoded strings with constants.

Comment on lines 706 to +711
params=query_result.to_json().replace("\\", "\\\\").replace('"', '\\"'),
)
html_content = html_content.replace(
'"graph_visualization.Query"', '"bigquery.graph_visualization.Query"'
)
html_content = html_content.replace(

Choose a reason for hiding this comment

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

medium

The callback names are hardcoded here and also when registering the callbacks on lines 683 and 685. To improve maintainability and prevent potential bugs if these names need to be changed in the future, it would be better to define these strings as constants at the module level and reuse them in all relevant places.

For example:

# At module level
_BQ_GRAPH_QUERY_CALLBACK = "bigquery.graph_visualization.Query"
_BQ_GRAPH_NODE_EXPANSION_CALLBACK = "bigquery.graph_visualization.NodeExpansion"
_SPANNER_GRAPH_QUERY_CALLBACK = "graph_visualization.Query"
_SPANNER_GRAPH_NODE_EXPANSION_CALLBACK = "graph_visualization.NodeExpansion"

# In _add_graph_widget()
...
output.register_callback(_BQ_GRAPH_QUERY_CALLBACK, _colab_query_callback)
...
html_content = html_content.replace(
    f'\"{_SPANNER_GRAPH_QUERY_CALLBACK}\"', f'\"{_BQ_GRAPH_QUERY_CALLBACK}\"'
)
...

@tswast tswast marked this pull request as ready for review February 4, 2026 15:27
@tswast tswast requested review from a team as code owners February 4, 2026 15:27
@tswast tswast requested a review from jialuoo February 4, 2026 15:27
@tswast tswast changed the title chore: Make the name of the colab endpoint unique between BigQuery an… fix: reduce conflicts between Spanner and BigQuery graph visualization on Colab Feb 4, 2026
@tswast tswast merged commit 7dca7b1 into main Feb 4, 2026
25 checks passed
@tswast tswast deleted the colab branch February 4, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery-magics API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants