broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT k,COUNT(*) FROM a WHERE k IS NOT NULL GROUP BY k HAVING COUNT(*)>1')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [['a', 5]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [['a', 5]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [['a', 5]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [['a', 5]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [['a', 5]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [['p', 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)

evaluation_group: xs-partial-index-conflicts

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT k,COUNT(*) FROM a WHERE k IS NOT NULL AND flag IS NOT NULL GROUP BY k HAVING COUNT(*)>1')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [['a', 5]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [['a', 5]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [['a', 5]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [['a', 5]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [['a', 5]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [['p', 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:
The query violates its result contract: counts rows excluded from the partial index.

Return duplicate known k counts only among rows with true flags, matching a WHERE flag partial unique index. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT k,COUNT(*) FROM a WHERE k IS NOT NULL AND flag IS NOT NULL GROUP BY k HAVING COUNT(*)>1')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [['a', 5]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [['a', 5]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [['a', 5]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [['a', 5]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [['a', 5]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [['p', 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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

evaluation_group: xs-partial-index-conflicts

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT k,COUNT(*) FROM a WHERE k IS NOT NULL AND flag=1 GROUP BY k HAVING COUNT(*)>1')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [['a', 5]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [['a', 5]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [['a', 5]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [['a', 5]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [['a', 5]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [['p', 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:
The query violates its result contract: indexes known false rows along with true rows.

Return duplicate known k counts only among rows with true flags, matching a WHERE flag partial unique index. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT k,COUNT(*) FROM a WHERE k IS NOT NULL AND flag=1 GROUP BY k HAVING COUNT(*)>1')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [['a', 5]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [['a', 5]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [['a', 5]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [['a', 5]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [['a', 5]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [['p', 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)

evaluation_group: xs-partial-index-conflicts

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT k,COUNT(*) FROM a WHERE k IS NOT NULL GROUP BY k HAVING COUNT(*)>1 AND MAX(flag)')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [['a', 5]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [['a', 5]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [['a', 5]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [['a', 5]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [['p', 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [['a', 5]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [['a', 5]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [['n', 2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [['p', 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:
The query violates its result contract: excludes non-one true flags from the index.

Return duplicate known k counts only among rows with true flags, matching a WHERE flag partial unique index. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access