Skip to content

Commit f393623

Browse files
rustyconoverclaude
andcommitted
splits: emit the canonical cross-SDK filter rendering
The dynamic-filter fixture echoed `repr(PushdownFilters)`, which no other SDK can reproduce — so the shared assertion on it could only ever pass here. _render_filters_canonical replaces it: sorted `col>=min` / `col<=max` from get_column_bounds, normalized to inclusive integers so Rust (whose ColumnBounds has no inclusive flag) renders the same bytes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 470656e commit f393623

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

‎vgi/_test_fixtures/table/splits.py‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,6 @@ def process(
10431043
out: OutputCollector,
10441044
) -> None:
10451045
"""Emit a batch, stamping every row with the filter this tick carried."""
1046-
from vgi._test_fixtures.table.filters import _format_pushed_filters_safe
1047-
10481046
while True:
10491047
if state.idx >= len(state.lo):
10501048
out.finish()
@@ -1069,7 +1067,7 @@ def process(
10691067
merged = cls.pushdown_filters(init.pushdown_filters, join_keys=init.join_keys)
10701068
if merged is None:
10711069
merged = params.current_pushdown_filters
1072-
filter_str = _format_pushed_filters_safe(merged)
1070+
filter_str = _render_filters_canonical(merged)
10731071
values = list(range(state.cur, end))
10741072
out.emit(
10751073
pa.RecordBatch.from_pydict(
@@ -1081,6 +1079,41 @@ def process(
10811079
return
10821080

10831081

1082+
def _render_filters_canonical(filters: object) -> str:
1083+
"""The CANONICAL cross-SDK rendering of a pushed-down filter set.
1084+
1085+
Every SDK must produce this byte-for-byte, because the shared SQL suite
1086+
asserts on the string. A language's own debug formatting cannot be used —
1087+
``repr(PushdownFilters)`` is Python-shaped and no other SDK can reproduce it,
1088+
so a test asserting it could only ever pass against this worker, which
1089+
defeats the point of a shared suite.
1090+
1091+
So it renders from ``get_column_bounds``, which every SDK mirrors: for each
1092+
filtered column in sorted order, ``col>=min`` and/or ``col<=max``, joined by
1093+
``,``. Values are included deliberately — without them a tightening Top-N
1094+
filter and a loose one render identically and the test cannot tell them apart.
1095+
"""
1096+
if filters is None:
1097+
return "(none)"
1098+
columns = sorted({f.column_name for f in filters.filters if getattr(f, "column_name", None)})
1099+
parts: list[str] = []
1100+
for c in columns:
1101+
bounds = filters.get_column_bounds(c)
1102+
if bounds is None:
1103+
continue
1104+
# Normalized to INCLUSIVE integer bounds, because that is the only form
1105+
# every SDK can produce: Rust's ColumnBounds is integer-coerced and
1106+
# carries no inclusive flag at all, so `n > 40` must render as `n>=41`
1107+
# here or the two workers disagree on a byte.
1108+
if bounds.min_value is not None:
1109+
lo = int(bounds.min_value) + (0 if bounds.min_inclusive else 1)
1110+
parts.append(f"{c}>={lo}")
1111+
if bounds.max_value is not None:
1112+
hi = int(bounds.max_value) - (0 if bounds.max_inclusive else 1)
1113+
parts.append(f"{c}<={hi}")
1114+
return ",".join(parts) if parts else "(none)"
1115+
1116+
10841117
@bind_fixed_schema
10851118
class SplitCacheableFunction(_SplitBase):
10861119
"""A split scan whose result is cacheable, so never-partial is assertable.

0 commit comments

Comments
 (0)