-
Notifications
You must be signed in to change notification settings - Fork 135
chore: Support dml_batch_update_count option in PG dialect #4142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5f1b158
to
6a5b11f
Compare
"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"; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
...le-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionProperties.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/DmlBatch.java
Show resolved
Hide resolved
"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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
...-spanner/src/main/resources/com/google/cloud/spanner/connection/PG_ClientSideStatements.json
Show resolved
Hide resolved
...-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java
Outdated
Show resolved
Hide resolved
public void testDmlBatchUpdateCount() { | ||
SpannerPool.closeSpannerPool(); | ||
mockSpanner.putStatementResult( | ||
MockSpannerServiceImpl.StatementResult.detectDialectResult(Dialect.POSTGRESQL)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" | ||
} | ||
}, | ||
{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
e436f29
to
1000fdc
Compare
base_branch: main | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: actions/checkout@v4 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
...oud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json
Outdated
Show resolved
Hide resolved
...oud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json
Outdated
Show resolved
Hide resolved
@olavloite addressed the comments. |
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) ORset local dml_batch_update_count = 1
(GoogleSQL) this will ensure updateCount for batch operations will always return 1(not auto batch dml).