Skip to content

Conversation

sakthivelmanii
Copy link
Collaborator

@sakthivelmanii sakthivelmanii commented Oct 7, 2025

Description:

Support setting batch DML update count for Postgres and GoogleSQL Dialect. When customer execute set local spanner.dml_batch_update_count to 1(Postgres) OR set local dml_batch_update_count = 1(GoogleSQL) this will ensure updateCount for batch operations will always return 1(not auto batch dml).

@sakthivelmanii sakthivelmanii requested review from a team as code owners October 7, 2025 16:54
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/java-spanner API. labels Oct 7, 2025
@sakthivelmanii sakthivelmanii changed the title chore: Support batch_dml_update_count option in PG dialect chore: Support dml_batch_update_count option in PG dialect Oct 7, 2025
@sakthivelmanii sakthivelmanii force-pushed the support_batch_dml_update_count branch 4 times, most recently from 5f1b158 to 6a5b11f Compare October 7, 2025 17:24
"auto_batch_dml_update_count";
public static final String AUTO_BATCH_DML_UPDATE_COUNT_VERIFICATION_PROPERTY_NAME =
"auto_batch_dml_update_count_verification";
public static final String DML_BATCH_UPDATE_COUNT_PROPERTY_NAME = "dml_batch_update_count";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that the name batch_dml_update_count would be better, as it more in line with auto_batch_dml_update_count.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@olavloite I initially named it that way. I changed it by thinking that it would be breaking change since PGAdapter supports this way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, that is a good point. PGAdapter will automatically use the implementation in the Connection API in a case like that. If the behavior is exactly the same, then that should then not be a problem. But it might be good to verify that by running the PGAdapter tests locally with version of the client library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

"exampleStatements": [
"set local spanner.dml_batch_update_count = 0",
"set local spanner.dml_batch_update_count = 100",
"set local spanner.dml_batch_update_count to 1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: add an example statement that does not use local. The test generator uses these example statements to generate tests, so adding an example without local also means that you get tests for this statement without the local keyword.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am wondering do we need to support session itself? is local not enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

public void testDmlBatchUpdateCount() {
SpannerPool.closeSpannerPool();
mockSpanner.putStatementResult(
MockSpannerServiceImpl.StatementResult.detectDialectResult(Dialect.POSTGRESQL));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test should test both dialects

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. It didn't run for both. I have made changes to run it for both.

"converterName": "ClientSideStatementValueConverters$LongConverter"
}
},
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Run the following command in the google-cloud-spanner folder:

mvn -Ddo_log_statements=true exec:java -Dexec.mainClass=com.google.cloud.spanner.connection.SqlTestScriptsGenerator -Dexec.classpathScope="test"

This will generate tests for the new statements that you have added to the client-side statement file(s).

See ConnectionImplGeneratedSqlScriptTest for more information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@sakthivelmanii sakthivelmanii force-pushed the support_batch_dml_update_count branch from e436f29 to 1000fdc Compare October 9, 2025 15:27
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: m Pull request size is medium. labels Oct 9, 2025
olavloite
olavloite previously approved these changes Oct 10, 2025
base_branch: main
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: undo unrelated change? (Maybe in a follow-up PR)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's automatically added by bot.

@sakthivelmanii
Copy link
Collaborator Author

@olavloite addressed the comments.

@olavloite olavloite merged commit ece1390 into main Oct 10, 2025
42 checks passed
@olavloite olavloite deleted the support_batch_dml_update_count branch October 10, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants