broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row['id']
            for column in columns:
                if column not in row: continue
                if row.get(column) is not None: result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row['id']
            for column in columns:
                if column not in row: continue
                if row.get(column): result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

prompt:
Unpivot removes explicitly stored null field values.

Unpivot selected columns of record dictionaries into [id,column,value] rows. Include explicitly present None values, skip absent columns, respect requested column order and repetitions, and retain parent row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row['id']
            for column in sorted(columns):
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row['id']
            for column in reversed(columns):
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

prompt:
Unpivot iterates selected columns in sorted name order.

Unpivot selected columns of record dictionaries into [id,column,value] rows. Include explicitly present None values, skip absent columns, respect requested column order and repetitions, and retain parent row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row['id']
            for column in dict.fromkeys(columns):
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row['id']
            for column in sorted(set(columns)):
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

prompt:
Unpivot deduplicates repeated selected columns.

Unpivot selected columns of record dictionaries into [id,column,value] rows. Include explicitly present None values, skip absent columns, respect requested column order and repetitions, and retain parent row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=rows.index(row)
            for column in columns:
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in rows:
            ident=row.get(columns[0]) if columns else None
            for column in columns:
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

prompt:
Unpivot uses row position instead of the identity column.

Unpivot selected columns of record dictionaries into [id,column,value] rows. Include explicitly present None values, skip absent columns, respect requested column order and repetitions, and retain parent row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in sorted(rows,key=lambda r:r["id"]):
            ident=row['id']
            for column in columns:
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,columns=d
        result=[]
        for row in reversed(rows):
            ident=row['id']
            for column in columns:
                if column not in row: continue
                result.append([ident,column,row.get(column)])
        return result
    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('source column order', solve([[{'id': 9, 'a': 1, 'b': 2}], ['b', 'a']]), [[9, 'b', 2], [9, 'a', 1]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 1}], ['a', 'b']]), [[9, 'a', 1]])
    check('duplicate column', solve([[{'id': 9, 'a': 1}], ['a', 'a']]), [[9, 'a', 1], [9, 'a', 1]])
    check('parent order', solve([[{'id': 9, 'a': 1}, {'id': 2, 'a': 2}], ['a']]), [[9, 'a', 1], [2, 'a', 2]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 1}], []]), [])
elif N == 2:
    check('source column order', solve([[{'id': 9, 'a': 2, 'b': 3}], ['b', 'a']]), [[9, 'b', 3], [9, 'a', 2]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 2}], ['a', 'b']]), [[9, 'a', 2]])
    check('duplicate column', solve([[{'id': 9, 'a': 2}], ['a', 'a']]), [[9, 'a', 2], [9, 'a', 2]])
    check('parent order', solve([[{'id': 9, 'a': 2}, {'id': 2, 'a': 3}], ['a']]), [[9, 'a', 2], [2, 'a', 3]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 2}], []]), [])
elif N == 3:
    check('source column order', solve([[{'id': 9, 'a': 3, 'b': 4}], ['b', 'a']]), [[9, 'b', 4], [9, 'a', 3]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 3}], ['a', 'b']]), [[9, 'a', 3]])
    check('duplicate column', solve([[{'id': 9, 'a': 3}], ['a', 'a']]), [[9, 'a', 3], [9, 'a', 3]])
    check('parent order', solve([[{'id': 9, 'a': 3}, {'id': 2, 'a': 4}], ['a']]), [[9, 'a', 3], [2, 'a', 4]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 3}], []]), [])
elif N == 4:
    check('source column order', solve([[{'id': 9, 'a': 4, 'b': 5}], ['b', 'a']]), [[9, 'b', 5], [9, 'a', 4]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 4}], ['a', 'b']]), [[9, 'a', 4]])
    check('duplicate column', solve([[{'id': 9, 'a': 4}], ['a', 'a']]), [[9, 'a', 4], [9, 'a', 4]])
    check('parent order', solve([[{'id': 9, 'a': 4}, {'id': 2, 'a': 5}], ['a']]), [[9, 'a', 4], [2, 'a', 5]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 4}], []]), [])
elif N == 5:
    check('source column order', solve([[{'id': 9, 'a': 5, 'b': 6}], ['b', 'a']]), [[9, 'b', 6], [9, 'a', 5]])
    check('explicit null', solve([[{'id': 9, 'a': None}], ['a']]), [[9, 'a', None]])
    check('missing field', solve([[{'id': 9, 'a': 5}], ['a', 'b']]), [[9, 'a', 5]])
    check('duplicate column', solve([[{'id': 9, 'a': 5}], ['a', 'a']]), [[9, 'a', 5], [9, 'a', 5]])
    check('parent order', solve([[{'id': 9, 'a': 5}, {'id': 2, 'a': 6}], ['a']]), [[9, 'a', 5], [2, 'a', 6]])
    check('zero value', solve([[{'id': 9, 'a': 0}], ['a']]), [[9, 'a', 0]])
    check('empty projection', solve([[{'id': 9, 'a': 5}], []]), [])
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)

prompt:
Unpivot sorts parents by identity before expansion.

Unpivot selected columns of record dictionaries into [id,column,value] rows. Include explicitly present None values, skip absent columns, respect requested column order and repetitions, and retain parent row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k%buckets==key%buckets and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

prompt:
Hash-join probe treats bucket equality as key equality.

Probe a toy hash join whose hash bucket is integer key modulo bucket-count. Return left/right IDs for ordinary equal non-null keys AND right score>=left floor. Preserve all matching build rows and probe order. Hash equality alone never establishes row equality.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=0: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

prompt:
Hash-join probe omits its non-equality residual.

Probe a toy hash join whose hash bucket is integer key modulo bucket-count. Return left/right IDs for ordinary equal non-null keys AND right score>=left floor. Preserve all matching build rows and probe order. Hash equality alone never establishes row equality.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table[key%buckets]=[[ident,key,score]]
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[[ident,key,score]])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

prompt:
Hash-join build buckets retain only the final row.

Probe a toy hash join whose hash bucket is integer key modulo bucket-count. Return left/right IDs for ordinary equal non-null keys AND right score>=left floor. Preserve all matching build rows and probe order. Hash equality alone never establishes row equality.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(ident%buckets,[]):
                if k==key and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(floor%buckets,[]):
                if k==key and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

prompt:
Hash-join probe computes bucket from row identity.

Probe a toy hash join whose hash bucket is integer key modulo bucket-count. Return left/right IDs for ordinary equal non-null keys AND right score>=left floor. Preserve all matching build rows and probe order. Hash equality alone never establishes row equality.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(score%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(ident%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=floor: out.append([ident,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

prompt:
Hash-join build indexes buckets by payload score.

Probe a toy hash join whose hash bucket is integer key modulo bucket-count. Return left/right IDs for ordinary equal non-null keys AND right score>=left floor. Preserve all matching build rows and probe order. Hash equality alone never establishes row equality.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=floor: out.append([ident,k])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        left,right,buckets=d
        table={}
        for ident,key,score in right:
            if key is None: continue
            table.setdefault(key%buckets,[]).append([ident,key,score])
        out=[]
        for ident,key,floor in left:
            if key is None: continue
            for other,k,score in table.get(key%buckets,[]):
                if k==key and score>=floor: out.append([key,other])
        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('colliding keys', solve([[[10, 1, 1]], [[20, 1, 1], [21, 4, 1]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 2]], [[20, 1, 1]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 1]], [[20, 1, 1], [21, 1, 2]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 6]], [[20, 4, 7]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]], 3]), [])
    check('empty build', solve([[[10, 1, 1]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 1]], 3]), [])
elif N == 2:
    check('colliding keys', solve([[[10, 1, 2]], [[20, 1, 2], [21, 4, 2]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 3]], [[20, 1, 2]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 2]], [[20, 1, 2], [21, 1, 3]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 7]], [[20, 4, 8]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]], 3]), [])
    check('empty build', solve([[[10, 1, 2]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 2]], 3]), [])
elif N == 3:
    check('colliding keys', solve([[[10, 1, 3]], [[20, 1, 3], [21, 4, 3]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 4]], [[20, 1, 3]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 3]], [[20, 1, 3], [21, 1, 4]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 8]], [[20, 4, 9]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]], 3]), [])
    check('empty build', solve([[[10, 1, 3]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 3]], 3]), [])
elif N == 4:
    check('colliding keys', solve([[[10, 1, 4]], [[20, 1, 4], [21, 4, 4]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 5]], [[20, 1, 4]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 4]], [[20, 1, 4], [21, 1, 5]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 9]], [[20, 4, 10]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]], 3]), [])
    check('empty build', solve([[[10, 1, 4]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 4]], 3]), [])
elif N == 5:
    check('colliding keys', solve([[[10, 1, 5]], [[20, 1, 5], [21, 4, 5]], 3]), [[10, 20]])
    check('residual rejects', solve([[[10, 1, 6]], [[20, 1, 5]], 3]), [])
    check('build multiplicity', solve([[[10, 1, 5]], [[20, 1, 5], [21, 1, 6]], 3]), [[10, 20], [10, 21]])
    check('probe bucket', solve([[[11, 4, 10]], [[20, 4, 11]], 3]), [[11, 20]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]], 3]), [])
    check('empty build', solve([[[10, 1, 5]], [], 3]), [])
    check('empty probe', solve([[], [[20, 1, 5]], 3]), [])
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)

prompt:
Hash join emits matched keys instead of build row IDs.

Probe a toy hash join whose hash bucket is integer key modulo bucket-count. Return left/right IDs for ordinary equal non-null keys AND right score>=left floor. Preserve all matching build rows and probe order. Hash equality alone never establishes row equality.

split: open-access


broken_source:
"""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 False: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in 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)

source:
"""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]==left[i]: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in 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)

prompt:
Merge join matches only the first row of a repeated left key.

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.

split: open-access