Uh oh!
There was an error while loading. Please reload this page.
[SPARK-19335][SPARK-38200][SQL] Add upserts for writing to JDBC using MERGE INTO with temp table - #41611
Closed
EnricoMi wants to merge 17 commits into
Closed
[SPARK-19335][SPARK-38200][SQL] Add upserts for writing to JDBC using MERGE INTO with temp table#41611EnricoMi wants to merge 17 commits into
EnricoMi wants to merge 17 commits into
Conversation
EnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
June 15, 2023 09:39
7a0e4d2 to
9cc6b39CompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
3 times, most recently
from
June 16, 2023 06:57
1ade6b4 to
76d0429CompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
June 23, 2023 10:23
76d0429 to
0439e5dCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
June 30, 2023 09:34
95dc877 to
265dd1fCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
July 18, 2023 12:46
265dd1f to
2c3faecCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
July 26, 2023 12:32
cdb889d to
db2d78dCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
October 9, 2023 13:39
db2d78d to
464a19aCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
2 times, most recently
from
October 26, 2023 10:21
7658bbc to
80a2a9cCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
December 1, 2023 15:31
80a2a9c to
d064da1CompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
January 10, 2024 19:46
d064da1 to
5e69410CompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
3 times, most recently
from
January 23, 2024 09:04
38ce6b9 to
60e41caCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
April 20, 2024 16:19
10fd22b to
e3ade6eCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
June 7, 2024 20:46
e3ade6e to
4edb30aCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
2 times, most recently
from
September 2, 2024 16:43
637ca4f to
72527beCompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
2 times, most recently
from
November 22, 2024 15:35
9d72693 to
acb6131CompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
January 16, 2025 14:20
acb6131 to
5146227CompareEnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
March 5, 2025 13:16
5146227 to
d1f32efCompareDerby does not support indices on temp tables: https://db.apache.org/derby/docs/10.2/ref/rrefdeclaretemptable.html
EnricoMiforce-pushed
the
jdbc-upsert-merge-temp-table
branch
from
April 28, 2025 04:49
d1f32ef to
583d349CompareWe're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. |
This was referenced Feb 24, 2026
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 freeto 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.
What changes were proposed in this pull request?
Implements upsert mode for
SaveMode.Appendof the MsSql, Postgres, Derby, H2 and oracle JDBC source.This uses
MERGE INTOin combination with a temporary table. A batch of rows is inserted into the temporary table (rather than the target table) and merged into the target table with oneMERGE INTOcommand per batch.See #41518 for an alternative for databases not supporting
MERGE INTOsyntax.Why are the changes needed?
The JDBC writer only supports either truncating the existing table or inserting. Duplicates, i.e. rows with identical values in the primary or unique index columns, cause an exception, permitting updating existing and inserting new rows.
Re-evaluating a partition due to executor loss will insert rows that have been inserted in an earlier attempt, which kills the entier Spark job.
Does this PR introduce any user-facing change?
This adds
upsertandupsertKeyColumnsoptions forSaveMode.Appendof the JDBC source.How was this patch tested?
Tests in
JdbcSuiteand integration suites.