Skip to content

Add IMPORT/EXPORT support for expression indexes - #4455

Draft
tinaspark wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
tinaspark:main
Draft

tinaspark wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
tinaspark:main

Conversation

@tinaspark

Copy link
Copy Markdown
Contributor

No description provided.

@tinaspark
tinaspark requested a review from a team as a code owner October 19, 2026 22:35
@google-cla

google-cla Bot commented Oct 19, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@tinaspark
tinaspark marked this pull request as draft October 19, 2026 22:35
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces support for expression indexes within the Spanner DDL utility. By updating the core index column models and the schema scanner, the system can now correctly identify, parse, and represent indexes defined by expressions rather than simple column references. This enhancement ensures that data migration and schema conversion tools can handle modern Spanner index features, verified through updated unit tests for both supported SQL dialects.

Highlights

  • Expression Index Support: Added support for expression-based indexes in Spanner DDL, allowing for more complex index definitions.
  • Schema Scanning Updates: Updated InformationSchemaScanner to correctly fetch and process expression columns from the database schema.
  • Test Coverage: Expanded AvroSchemaToDdlConverterTest to include validation for expression indexes in both Google Standard SQL and PostgreSQL dialects.
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 the 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 counterproductive. 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.

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. ↩

@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 introduces support for expression-based index columns in Spanner DDL by adding an expression property to IndexColumn and updating InformationSchemaScanner to retrieve this field from the information schema. However, the current implementation contains several critical compilation and runtime issues. These include a missing @nullable annotation on the AutoValue expression() method, multiple syntax and type errors in IndexColumn.prettyPrint(), a casing typo on ResultSet.getString(), an invalid boolean check on a String variable, and trailing commas in the SQL select statements that will cause syntax errors at runtime.

Comment on lines +84 to +89
if (expression == null) {
appendable.append(quoteIdentifier(name(), dialect()));
} else {
appendable.append("(").append(expression.append(")");
}
appendable..append(" ").append(order().title);

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.

critical

There are multiple compilation and syntax errors in this block:

  1. expression is an abstract method, so it must be called as expression().
  2. expression.append(")") is invalid because String does not have an append method.
  3. appendable..append contains a double dot syntax error.
Suggested change
if (expression == null) {
appendable.append(quoteIdentifier(name(), dialect()));
} else {
appendable.append("(").append(expression.append(")");
}
appendable..append(" ").append(order().title);
if (expression() == null) {
appendable.append(quoteIdentifier(name(), dialect()));
} else {
appendable.append("(\n").append(expression()).append(")");
}
appendable.append(" ").append(order().title);

String indexLocalName = resultSet.getString(4);
String indexType = resultSet.getString(5);
String spannerType = resultSet.getString(6);
String expression = resultSet.GetString(7);

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.

critical

The method GetString does not exist on ResultSet. It should be lowercase getString.

Suggested change
String expression = resultSet.GetString(7);
String expression = resultSet.getString(7);

Comment on lines +603 to +605
if (expression) {
indexColumnsBuilder.expression(expression);
}

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.

critical

In Java, a String cannot be used directly as a boolean condition in an if statement. You must check if it is not null.

Suggested change
if (expression) {
indexColumnsBuilder.expression(expression);
}
if (expression != null) {
indexColumnsBuilder.expression(expression);
}

@tinaspark
tinaspark force-pushed the main branch 5 times, most recently from 176981f to 4685cd6 Compare October 20, 2026 15:26
addition: Add IMPORT/EXPORT support for expression indexes
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.03%. Comparing base (5eba605) to head (2e7fa17).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...google/cloud/teleport/spanner/ddl/IndexColumn.java 25.00% 5 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (25.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4455      +/-   ##
============================================
+ Coverage     57.01%   57.03%   +0.01%     
- Complexity     7578     7581       +3     
============================================
  Files          1156     1156              
  Lines         73754    73761       +7     
  Branches       8698     8699       +1     
============================================
+ Hits          42052    42066      +14     
+ Misses        28900    28894       -6     
+ Partials       2802     2801       -1     
Components Coverage Δ
spanner-templates 84.57% <ø> (ø)
spanner-import-export 72.11% <25.00%> (+0.10%) ⬆️
spanner-live-forward-migration 89.02% <ø> (ø)
spanner-live-reverse-replication 80.93% <ø> (ø)
spanner-bulk-migration 89.01% <ø> (ø)
gcs-spanner-dv 88.07% <ø> (ø)
Files with missing lines Coverage Δ
...google/cloud/teleport/spanner/ddl/IndexColumn.java 83.52% <25.00%> (-6.22%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant