Fix supportsBatchUpdates() to honor EnableBatchedInserts#1496
Open
sreekanth-db wants to merge 1 commit into
Open
Fix supportsBatchUpdates() to honor EnableBatchedInserts#1496sreekanth-db wants to merge 1 commit into
sreekanth-db wants to merge 1 commit into
Conversation
DatabricksDatabaseMetaData.supportsBatchUpdates() was hard-coded to return false. Batch-aware JDBC clients (e.g. Apache Hop) call this method before batching; seeing false, they never call executeBatch() and fall back to one executeUpdate() per row, so the multi-row INSERT optimization gated by EnableBatchedInserts never runs. Return true when EnableBatchedInserts=1 so those clients use the optimized executeBatch() path. Default behavior is unchanged (flag off -> false). Mirrors the existing context-driven supportsTransactions(). Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DatabricksDatabaseMetaData.supportsBatchUpdates()was hard-coded to returnfalse. Batch-aware JDBC clients (e.g. Apache Hop) call this method before batching; when it returnsfalsethey never callexecuteBatch()and instead fall back to oneexecuteUpdate()per row. As a result, the multi-row INSERT optimization gated byEnableBatchedInserts(added in #944) never runs — even when the customer explicitly setsEnableBatchedInserts=1.This PR makes
supportsBatchUpdates()returntruewhenEnableBatchedInserts=1, so batch-aware clients take the optimizedexecuteBatch()path.Fixes ES-1963495.
Why gate on
EnableBatchedInsertsrather than returntrueunconditionallyfalse, so default behavior is untouched. This preserves the deliberate "safe rollout" posture chosen in Implement multi-row INSERT batching for PreparedStatement #944.executeBatch()routes INSERTs through the optimized multi-row path; the metadata answer now matches real behavior.supportsTransactions()in the same class is already derived from a connection parameter (IgnoreTransactions), so a context-driven capability method is an established pattern here.Spec / conformance notes
supportsBatchUpdates()must returntrue. The driver does implement a workingexecuteBatch()(it handles all DML types; only INSERTs are optimized, others fall back to per-row), sotrueis the conformant value.true.truewhile gating their multi-row INSERT rewrite behind a separate flag (rewriteBatchedStatements/reWriteBatchedInserts, both default-off).Changes
DatabricksDatabaseMetaData.supportsBatchUpdates()returnsisBatchedInsertsEnabled()instead offalse.supportsBatchUpdates_returnsTrueWhenBatchedInsertsEnabled; renamed the existing case tosupportsBatchUpdates_returnsFalseByDefault.NEXT_CHANGELOG.mdentry under### Fixed.Testing
mvn test -pl jdbc-core -Dtest=DatabricksDatabaseMetaDataTest→ 249 run, 0 failures, 0 skipped (both new/updated cases included).