fix: reduce conflicts between Spanner and BigQuery graph visualization on Colab by ericfe-google · Pull Request #209 · googleapis/python-bigquery-magics · GitHub
Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

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

Merged
tswast merged 1 commit into
mainfrom
colab
Feb 4, 2026
Merged

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

Conversation

@ericfe-google

Copy link
Copy Markdown
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
Copy Markdown
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.

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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 and 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
tswast added a commit that referenced this pull request Feb 10, 2026
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.8.0
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:1a2a85ab507aea26d787c06cc7979decb117164c81dd78a745982dfda80d4f68
<details><summary>bigquery-magics: 0.12.0</summary>

##
[0.12.0](v0.11.0...v0.12.0)
(2026-02-10)

### Features

* support schema view (#211)
([8e1883e](8e1883ee))

* remove bqsql magic to make that name available for bigframes (#210)
([c46c94a](c46c94af))

### Bug Fixes

* reduce conflicts between Spanner and BigQuery graph visualization on
Colab (#209)
([7dca7b1](7dca7b13))

</details>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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