diff --git a/interactive/Cargo.toml b/interactive/Cargo.toml index b3e3a028d..b730cf48d 100644 --- a/interactive/Cargo.toml +++ b/interactive/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] columnar = { workspace = true } # The columnar kernels for the interpreted backend, pinned by git rev. -corgi = { git = "https://github.com/frankmcsherry/wip", rev = "c4626fce02288594c9806e9b747a19598d680e0a" } +corgi = { git = "https://github.com/frankmcsherry/wip", rev = "cb26fbd29c223a97781891298a0cc7b5f94a5b2f" } differential-dataflow = { workspace = true } mimalloc = "0.1.48" serde = { version = "1.0", features = ["derive"] } diff --git a/interactive/tests/corgi_backend.rs b/interactive/tests/corgi_backend.rs index 31db6d137..ca50f5332 100644 --- a/interactive/tests/corgi_backend.rs +++ b/interactive/tests/corgi_backend.rs @@ -31,6 +31,9 @@ fn inputs_for(prog: &str) -> Vec> { // scalar_ops: (key, a, b) triples; a values straddle the `> 2` and `= -5` tests. "scalar_ops" => vec![rows(&[&[1, 1, 9], &[1, 4, 8], &[2, 3, 7], &[3, -5, 6], &[3, 2, 5]])], "sum_ops" => vec![rows(&[&[1, 10], &[2, 20], &[2, 21]])], + // sum_skew: any keyed pairs — the skew is in the program, not the data. + "sum_skew" => vec![rows(&[&[1, 10], &[2, 20], &[2, 21], &[3, 30]])], + "sum_skew_compiled" => vec![rows(&[&[1, 10], &[2, 20], &[2, 21], &[3, 30]])], "case_ops" => vec![rows(&[&[1, 10], &[2, 20], &[3, 14], &[3, 30]])], // pair_keys: composite keys with overlap, fanout, and one-sided keys on both sides. "pair_keys" => vec![ @@ -76,6 +79,8 @@ fn assert_backends_agree(prog: &str) { #[test] fn join_fallback() { assert_backends_agree("join_fallback"); } #[test] fn scalar_ops() { assert_backends_agree("scalar_ops"); } #[test] fn sum_ops() { assert_backends_agree("sum_ops"); } +#[test] fn sum_skew() { assert_backends_agree("sum_skew"); } +#[test] fn sum_skew_compiled() { assert_backends_agree("sum_skew_compiled"); } #[test] fn case_ops() { assert_backends_agree("case_ops"); } #[test] fn tour() { assert_backends_agree("tour"); } #[test] fn pair_keys() { assert_backends_agree("pair_keys"); } diff --git a/interactive/tests/programs/sum_skew.ddp b/interactive/tests/programs/sum_skew.ddp new file mode 100644 index 000000000..2fa9dbb58 --- /dev/null +++ b/interactive/tests/programs/sum_skew.ddp @@ -0,0 +1,18 @@ +-- Two collections that commit DIFFERENT variant arms, concatenated into one arrangement. +-- Neither side's shape names the whole variant universe: one infers `Sum([Some(_)])` +-- (tag 0 only), the other `Sum([None, Some(_)])` (tag 1 only) — two arities for one DDIR +-- type. corgi reads a differing Sum arity as a type error, so the two must be reconciled +-- with uncommitted (⊥) lanes before anything compares or gathers them. +-- +-- This is the ROW-WISE FALLBACK case: `hash` is a term corgi does not lower, so the shapes +-- here come from `infer_shape_cols` scanning the data. See `sum_skew_compiled.ddp` for the +-- same defect on the compiled path — both under-approximate, just from different sources. +con Rare(1) = 0; +con Common(1) = 1; + +let pairs = input 0 | key($0[0] ; $0[1]); + +let onlyRare = pairs | map( $0[0] ; Rare(hash(1000000, $1[0])) ); +let onlyCommon = pairs | map( $0[0] ; Common(hash(1000000, $1[0])) ); + +export "result" = (onlyRare + onlyCommon) | arrange | inspect(total); diff --git a/interactive/tests/programs/sum_skew_compiled.ddp b/interactive/tests/programs/sum_skew_compiled.ddp new file mode 100644 index 000000000..2a3a0251c --- /dev/null +++ b/interactive/tests/programs/sum_skew_compiled.ddp @@ -0,0 +1,16 @@ +-- `sum_skew.ddp` on the COMPILED path: no `hash`, so both maps lower to corgi logic. +-- +-- The compiled path derives shape from the TERM rather than the data, but that is no less +-- of an under-approximation: `infer_term_shape` gives `Inject(tag, _)` an arity of `tag + 1`, +-- so `Rare(_)` compiles to one lane and `Common(_)` to two. A single term reconciles its own +-- arms (`If` joins them), but two separate operators have nothing to reconcile them, and the +-- declared universe (`con`) that would is discarded at parse. +con Rare(1) = 0; +con Common(1) = 1; + +let pairs = input 0 | key($0[0] ; $0[1]); + +let onlyRare = pairs | map( $0[0] ; Rare($1[0]) ); +let onlyCommon = pairs | map( $0[0] ; Common($1[0]) ); + +export "result" = (onlyRare + onlyCommon) | arrange | inspect(total);