Skip to content

Commit d84d604

Browse files
ahrzbclaude
andcommitted
test(specializer): pin substr negative-start paths — column-path parity green, constant-fold divergence xfail-strict
The TASK-45-review substr report compared the engine's column path against DuckDB's constant-fold path. Measured (DuckDB 1.5.5): those two DuckDB paths disagree with each other on negative starts; the engine matches the vectorized path, per the builtin-pins spec §4 pin. Column-path triples from the report now pass differentially; the pure-literal known residual is documented as a strict xfail. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 25fc76d commit d84d604

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

tests/test_duckdb_interpreter.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,37 @@ def test_substr_negative_length_differential():
341341
)
342342

343343

344+
def test_substr_negative_start_column_path_differential():
345+
# The TASK-45-review "parity bug" triples, through the path real queries
346+
# take (column input -> DuckDB's vectorized substr). Both engines agree:
347+
# negative start clamps to 1 BEFORE the length window (builtin-pins \u00a74).
348+
duck_check(
349+
"SELECT substr(s, st, ln) AS r FROM __THIS__",
350+
{"s": "str", "st": "int", "ln": "int"},
351+
[
352+
{"s": "ab", "st": -4, "ln": 2},
353+
{"s": "ab", "st": -3, "ln": 2},
354+
{"s": "ab", "st": -5, "ln": 3},
355+
],
356+
)
357+
358+
359+
@pytest.mark.xfail(
360+
strict=True,
361+
reason="DuckDB's constant-fold substr disagrees with its own vectorized "
362+
"path on negative starts (const substr('ab',-4,2)='', vectorized='ab'; "
363+
"measured 1.5.5). The engine pins the vectorized path, so pure-literal "
364+
"negative-start substr diverges \u2014 known residual, builtin-pins spec \u00a74",
365+
)
366+
def test_substr_constant_fold_divergence():
367+
duck_check(
368+
"SELECT substr('ab', -4, 2) AS a, substr('ab', -3, 2) AS b, "
369+
"substr('ab', -5, 3) AS c FROM __THIS__",
370+
{"s": "str"},
371+
[{"s": "x"}],
372+
)
373+
374+
344375
def test_float_rendering_differential():
345376
duck_check(
346377
"SELECT x || '' AS s FROM __THIS__",

0 commit comments

Comments
 (0)