FA-44996 / Data systems / Open access
Merge join reverses left-run order while emitting pairs · case 01
Merge join reverses left-run order while emitting pairs.
ROOT CAUSE
merge-join-runs: Merge join reverses left-run order while emitting pairs.
THE FAILURE
merge-join-runs: Merge join reverses left-run order while emitting pairs.
Unsuccessful approach: Sorting IDs descending also changes the required physical tie order.
Case contract
Join two key-sorted non-null relations [key,id] by matching equal-key runs. Emit the full left-major Cartesian product for each matching run. Advance the lower unmatched run and preserve physical order within equal-key runs.
Why this case matters
A bounded deterministic data engine model makes representation and changelog faults reproducible.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
left,right=d
i=j=0; out=[]
while i<len(left) and j<len(right):
a=left[i][0]; b=right[j][0]
if a<b: i+=1; continue
if a>b: j+=1; continue
ie=i+1
while ie<len(left) and left[ie][0]==a: ie+=1
je=j+1
while je<len(right) and right[je][0]==b: je+=1
for x in reversed(left[i:ie]):
for y in right[j:je]: out.append([x[1],y[1]])
i,j=ie,je
return out
except (IndexError, KeyError, ValueError, StopIteration) as exc:
return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
check('empty left', solve([[], [[1, 20]]]), [])
check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
check('empty left', solve([[], [[2, 20]]]), [])
check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
check('empty left', solve([[], [[3, 20]]]), [])
check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
check('empty left', solve([[], [[4, 20]]]), [])
check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
check('empty left', solve([[], [[5, 20]]]), [])
check('empty right', solve([[[5, 10]], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| duplicate runs | [[11, 20], [11, 21], [10, 20], [10, 21]] | [[10, 20], [10, 21], [11, 20], [11, 21]] | Failed |
| left gap | [[11, 20]] | [[11, 20]] | Passed |
| right gap | [[10, 21]] | [[10, 21]] | Passed |
| single match | [[10, 20]] | [[10, 20]] | Passed |
| no overlap | [] | [] | Passed |
| empty left | [] | [] | Passed |
| empty right | [] | [] | Passed |
SHA-256 / 8b62c6666ed27d55a4ca001789165c9022db2d838be41310a0adf4a012ef4fa8
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
left,right=d
i=j=0; out=[]
while i<len(left) and j<len(right):
a=left[i][0]; b=right[j][0]
if a<b: i+=1; continue
if a>b: j+=1; continue
ie=i+1
while ie<len(left) and left[ie][0]==a: ie+=1
je=j+1
while je<len(right) and right[je][0]==b: je+=1
for x in sorted(left[i:ie],key=lambda r:-r[1]):
for y in right[j:je]: out.append([x[1],y[1]])
i,j=ie,je
return out
except (IndexError, KeyError, ValueError, StopIteration) as exc:
return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
check('empty left', solve([[], [[1, 20]]]), [])
check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
check('empty left', solve([[], [[2, 20]]]), [])
check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
check('empty left', solve([[], [[3, 20]]]), [])
check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
check('empty left', solve([[], [[4, 20]]]), [])
check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
check('empty left', solve([[], [[5, 20]]]), [])
check('empty right', solve([[[5, 10]], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| duplicate runs | [[11, 20], [11, 21], [10, 20], [10, 21]] | [[10, 20], [10, 21], [11, 20], [11, 21]] | Failed |
| left gap | [[11, 20]] | [[11, 20]] | Passed |
| right gap | [[10, 21]] | [[10, 21]] | Passed |
| single match | [[10, 20]] | [[10, 20]] | Passed |
| no overlap | [] | [] | Passed |
| empty left | [] | [] | Passed |
| empty right | [] | [] | Passed |
SHA-256 / 0e6b2b9eee25e3895809bc75b2cf6da24b5d98037d55c1726f39944344550b4f
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
Offline stipulated semantics over valid small inputs; no performance, concurrency, or production-engine conformance claim. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:44:17.685378+00:00.
Case digest / f5ada2e6f86d6cac8beeabdc9625d93aa1dfdd4145f083d325fc27be71e0749b