You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core)!: composite PK plumbing, Key API change, and Arrow filters (#453)
* feat(core)!: composite PK plumbing, Key API change, and Arrow filters
- Key API: replace `Key::to_arrow_datum` with `Key::to_arrow_datums` to supportmulti-component keys; update all builtin `Key` impls (ints/floats/string/date/time/timestamp/dynamic `Value`) to return a single-element Vec for single-PK types.
- Composite key showcase: add `Key2`/`Key2Ref` under `#[cfg(test)]` with `Encode`/`Decode`, `Ord`, `Hash`, `Key`/`KeyRef`; round-trip and ordering tests included.
- Parquet scan filtering: implement lexicographic composite range predicates in`get_range_filter` using `eq/gt/gt_eq/lt/lt_eq` with `and_kleene`/`or_kleene`; retain `_ts` upper-bound predicate.
- Scan plumbing: thread `pk_indices` through `SsTable::{get,scan}`, `Version::{query,streams,table_query}`, and `LevelStream`; update test callers. Build fixed projections as `[0, 1] ∪ pk_indices` in read paths.
- Docs: update composite PK RFC with “Current Status (2025-08-11)”; add draft RFC “Replace Schema Trait with Arrow Schema”.
- Clippy hygiene: remove needless range loops and redundant `.into_iter()`; add a focused `#[allow(clippy::too_many_arguments)]` on `Version::table_query`.
BREAKING CHANGE:
- `Key::to_arrow_datum` was replaced by `Key::to_arrow_datums(Vec<Arc<dyn Datum>>)`; external `Key` implementors must migrate to the new method (return one datum per PK component).
* refactor: remove unsafe code in src/ondisk/arrows.rs
Copy file name to clipboardExpand all lines: guide/src/contribution/composite_primary_keys.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,15 @@
2
2
3
3
This document outlines a practical, incremental plan to add composite (multi-column) primary key support to Tonbo while maintaining backward compatibility. It explains design goals, changes required across the codebase, and a step-by-step implementation and validation plan.
4
4
5
+
## Current Status (2025-08-11)
6
+
7
+
- Phase 1: Completed. Plural `Schema` APIs, fixed projections, and Parquet writer configuration are implemented for single-PK schemas.
8
+
-`Schema` now exposes `primary_key_indices()` and `primary_key_paths_and_sorting()` (src/record/mod.rs). Macro-generated single-PK schemas return one-element slices.
9
+
- Read paths build fixed projections as `[0, 1] ∪ PKs` using `primary_key_indices()` (src/lib.rs, src/transaction.rs).
10
+
-`DbOption::new` configures sorting columns (`_ts` then PKs) and enables stats + bloom filters for each PK column path (src/option.rs).
11
+
- Phase 2: Not implemented. Composite key types under `src/record/key/composite/` are placeholders; derive macro still accepts only a single `#[record(primary_key)]` and generates a single-field key. No multi-PK trybuild/integration tests.
12
+
- Phase 3: Not implemented. `DynSchema` remains single-PK (stores one `primary_index_arrow`, one `pk_path`, and sorting with a single PK column).
13
+
5
14
## Goals
6
15
7
16
- Support multi-column primary keys with lexicographic ordering of PK components.
0 commit comments