Repository navigation
Commit 952f5f7
authored
Feat/update from support (#42)
* test: deterministic e2e suite over full pgwire→WAL→Delta path
Adds an opt-in `e2e` cargo feature and dedicated CI job that exercises
the production write/read path against a per-test MinIO container with
virtual-time control, so flush, eviction, restart, and compaction paths
are covered end-to-end without wall-clock waits. Covers the prod class
of bug where queries silently stop returning.
- harness: testcontainers MinIO + frozen clock + pgwire client; per-test
WALRUS_DATA_DIR isolation; crash-and-restart helper that re-bootstraps
against the same data dir/bucket.
- scenarios: smoke, flush_lifecycle, eviction, cache_warmth (asserts
Foyer hit-or-no-S3-refetch), restart_recovery (flushed path),
multi_tenant_isolation, pressure_flush, zorder_idempotence (asserts
unchanged file set on second OPTIMIZE).
- proptest: row-count conservation, monotonic bucket id, clock advance.
- BufferedWriteLayer: flush/eviction `Notify` tick hooks, cumulative
flush counters in StatsSnapshot, `crash_for_test` (cancel without
graceful flush).
- bootstrap: shared wiring between main.rs and the harness so the test
path matches prod.
- CI: opt-in `e2e` job runs serialized (--test-threads=1) to keep WAL
isolation; main job stays untouched.
* feat: native UPDATE ... FROM end-to-end (planner → MergeBuilder + MemBuffer hash-join)
DataFusion's SQL planner recognizes `UPDATE ... FROM` and lowers it to a
joined Dml plan, TimeFusion's DmlQueryPlanner materializes the source RHS
once at plan-construction time, and both backends consume the result:
- Delta path dispatches to MergeBuilder with WHEN MATCHED THEN UPDATE,
using a conjunctive equi-join predicate built from the extracted keys.
- MemBuffer path does an in-memory hash join via Arrow RowConverter +
take, evaluating assignment exprs against a widened (target +
source__<name>) schema.
WAL gains a `WalOperation::UpdateWithSource = 3` variant carrying the
source as Arrow IPC bytes alongside the predicate + assignments, so
replay reconstructs the join exactly. V1 UPDATE entries continue to
decode.
`identify_target_side` unwraps Cast/TryCast on join keys (DataFusion
inserts implicit casts when source/target types differ slightly, e.g.
Utf8 vs Utf8View). `requalify_assignments_for_merge` rewrites the
user's source-alias references (e.g. `u.d` from `FROM (...) AS u`) to
`source.x` so delta-rs's MergeBuilder resolves them under its own
source alias.
Vendor datafusion-sql 53.1.0 with one patch: remove the defensive
`not_impl_err!("UPDATE ... FROM is not supported")` guard at
statement.rs:1087 (apache/datafusion#19950). The underlying
`update_to_plan` already handles `from` correctly via
`plan_from_tables`; the guard was a TODO that pre-dated the working
implementation a few hundred lines below. PATCHES.md documents the
diff.
Tests:
- test_update_from_values
- test_update_from_no_match_no_change
- test_update_from_with_predicate
- test_update_from_multi_column_set
All passing.
* add coverage for monoscope-shape UPDATE FROM + MemBuffer / WAL paths
- test_update_from_unnest_text_array: matches monoscope UPDATE-2 exactly
(text[] unnest source, user-alias `o`/`u`, list-typed assignment).
Confirms first-apply works end-to-end on the Delta MergeBuilder path.
- update_with_source_buffered_only + update_with_source_wal_replay_after_restart:
exercise the MemBuffer hash-join path and the WAL UpdateWithSource
serialization/replay loop. Both #[ignore]d: the buffered-only lookup
returns 0 matches because RowConverter requires byte-identical types
and our Utf8→Utf8View cast isn't producing comparable OwnedRow bytes.
Documented as a known follow-up.
- test_update_from_unnest_text_array_idempotent: #[ignore]d because
MergeBuilder counts WHEN MATCHED rows regardless of whether the SET
produces an unchanged value under the NOT @> predicate. Monoscope's
re-extraction safety on TF needs this nailed down separately.
Also reshape the merge rewriter:
- requalify_for_merge unifies the predicate + assignments paths. Strips
user aliases (o, u) and routes columns by schema membership: source-
schema columns → source.x, everything else → bare (target resolves).
- Pull join.filter (cross-side predicates like NOT @>) into the
predicate chain so MergeBuilder ANDs it into the join predicate.
- extract_dml_info handles SubqueryAlias passthrough and unwraps
implicit Cast/TryCast on join keys (DataFusion inserts these when
source/target types differ slightly).
- mem_buffer update_with_source now casts source key columns to target
key column types before hashing (Utf8 → Utf8View when needed).1 parent 695478d commit 952f5f7
72 files changed
Lines changed: 37703 additions & 22 deletions
File tree
- .github/workflows
- docs
- src
- tests
- e2e
- vendor/datafusion-sql
- examples
- src
- expr
- relation
- unparser
- tests
- cases
- common
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
| |||
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
177 | 193 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments