Skip to content

Batch replace#208

Merged
KirillKurdyukov merged 3 commits intoydb-platform:mainfrom
ppalex7:batchUpsert
Mar 13, 2026
Merged

Batch replace#208
KirillKurdyukov merged 3 commits intoydb-platform:mainfrom
ppalex7:batchUpsert

Conversation

@ppalex7
Copy link
Contributor

@ppalex7 ppalex7 commented Feb 25, 2026

New method that produces query like:

DECLARE $batch AS List<Struct<p1:Int64, p2:Int32? /* ... */>>;
REPLACE INTO `table` SELECT p1 AS `field1`, p2 AS `field2` /* , ... */ AS_TABLE($batch);

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

There is no convenient method to save multiple TableRecords if some of them already exists in the table.
You needed to manually process each record with ReplaceSetStep or separate insert and update queries.

Issue Number: N/A

What is the new behavior?

Just call batchReplace for prepared TableRecords.

        dsl.batchReplace(records)
                .execute();

Other information

Implementation is based on the code example from https://st.yandex-team.ru/YDBREQUESTS-7135#6995b34de0b1c77c03452994

@KirillKurdyukov KirillKurdyukov merged commit 1d13eca into ydb-platform:main Mar 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants