Skip to content

Conversation

@chenxuesdu
Copy link

Add a private variable isMutableKeyRange, which will be initialized during ChangeStreamDao constructor by reading from internal spanner table.

In function changeStreamQuery, when constructing change stream query, based on the value of isMutableKeyRange, call different TVFs when the Dialect is PostgreSQL(The googleSQL part is completed).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chenxuesdu, 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 enhances the Spanner change stream connector by introducing logic to adapt query behavior for PostgreSQL dialects based on the change stream's partition mode. Specifically, it allows the system to correctly query change streams that use either MUTABLE_KEY_RANGE or IMMUTABLE_KEY_RANGE partitioning by selecting the appropriate internal Spanner Table-Valued Function, ensuring proper data retrieval and compatibility.

Highlights

  • Dynamic TVF Selection for PostgreSQL: The ChangeStreamDao now dynamically selects between 'read_proto_bytes_' and 'read_json_' Table-Valued Functions (TVFs) for PostgreSQL change stream queries, based on the change stream's partition mode.
  • isMutableKeyRange Field: A new private boolean field, 'isMutableKeyRange', has been introduced in ChangeStreamDao to store the detected partition mode.
  • Constructor Initialization: The 'isMutableKeyRange' field is initialized during the ChangeStreamDao constructor by querying the 'information_schema.change_stream_options' table to determine the change stream's partition mode.
  • New Test File: A new test file, ChangeStreamDaoTest.java, has been added to validate the logic for determining and using the 'isMutableKeyRange' property.
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.

@chenxuesdu chenxuesdu changed the title Update ChangeStreamDao to query differnet TVF for postgresSQL based on the change stream partition mode Oct 29, 2025
@chenxuesdu chenxuesdu force-pushed the master branch 8 times, most recently from 473321f to 88ea37b Compare October 29, 2025 22:28
@github-actions
Copy link
Contributor

Assigning reviewers:

R: @m-trieu for label java.
R: @nielm for label spanner.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Statement.newBuilder(
"select option_name, option_value\n"
+ "from information_schema.change_stream_options\n"
+ "where change_stream_name = $1")

Choose a reason for hiding this comment

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

Can we add option_name = 'partition_mode' here so we can get the parititon mode directly and no need to filter later?

Statement.newBuilder(
"select option_name, option_value\n"
+ "from information_schema.change_stream_options\n"
+ "where change_stream_name = @changeStreamName")

Choose a reason for hiding this comment

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

same comment

query =
"SELECT * FROM \"spanner\".\"read_json_" + changeStreamName + "\"($1, $2, $3, $4, null)";
// Ensure we have determined whether change stream uses mutable key range
boolean isMutable = isMutableKeyRangeChangeStream();

Choose a reason for hiding this comment

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

Is this called each time we issue the query? As our query will be constantly checkpointed and canceled and re-issued, this can be called many times.

I think we just need to query the partition mode once for the whole pipeline.

@chenxuesdu chenxuesdu force-pushed the master branch 4 times, most recently from 5d1163c to d5f8b77 Compare October 31, 2025 04:55
the change stream partition mode

For MUTABLE_KEY_RANGE change stream, use read_proto_bytes_, else use read_json_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment