Repository navigation
[core] Use BTree indexes for upsert key lookups - #1198
Merged
JingsongLi merged 8 commits intoOct 22, 2026
Merged
Conversation
JingsongLi
force-pushed
the
codex/upsert-btree-key-lookup
branch
from
October 22, 2026 10:35
340e298 to
cd3dffe
Compare
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.
Purpose
Upserts, including the Python binding, currently plan a target scan without the incoming key predicates. Existing BTree indexes therefore cannot narrow key lookup. Push per-column key candidates into scan planning while retaining complete tuple matching for duplicates, NULLs, and partition identity.
Brief change log
IGNORE, compare relevant indexes' source snapshots against active files' key-column sequence numbers before pruning. Unchanged keys retain BTree acceleration after payload updates; changed or unverified keys use a complete lookup. Other current update policies bypass this freshness check. Inspection and lookup use one pinned snapshot.global_index_freshness, independent of Arrow input and the upsert executor. The caller supplies match columns and canonical partition identities. Build a centered file-range tree once per relevant partition/bucket, then inspect only overlapping physical column files for each index shard. Cache file row ranges and canonical split partitions rather than traversing all files per shard; nested and long ranges retain O(log F + overlaps) lookup cost.INdomains through composite indexes. Keep the 256-entry budget for Cartesian expansion, retaining an already-bound left prefix and independent suffix indexes when expansion exceeds it. Batch complete tuple point lookups withquery_inand cache normalized domain membership to avoid quadratic planning. Sort non-point prefix intervals and reuse their final data block, so even cache-disabled prefix queries read each target block once.Tests
IGNORE.IGNOREstill prunes unchanged keys and payload-only updates, honors per-column compaction sequences with compact or explicit write-column metadata, falls back for untrusted source metadata, and resumes pruning after index rebuilds.THROW_ERRORandDROP_PARTITION_INDEXretain BTree pruning without requiring source metadata. Added a regression for Java-padded NULL timestamp partitions.cargo test -p paimon --no-default-features --features storage-memory,storage-fs --lib -- btree:: table::table_upsert table::key_normalization table::upsert_key_matcher table::global_index_freshness table::global_index_scanner.git diff --checkpassed.API and Format
No public API or storage-format changes.
Documentation
Existing upsert API behavior is preserved; the change optimizes key lookup.