ktx/python/ktx-sl/tests
Luca Martial fb50c11d16
fix(sl): parse user filter expressions as predicates, not projections (#307)
* fix(sl): parse user filter expressions as predicates, not projections

User-authored filters and segments were parsed in a projection context
(`SELECT {expr}`). On T-SQL a top-level `col = 'value'` projection is the
`alias = expression` aliasing syntax, so an equality filter parsed this way
became `'value' AS col` — dropping the comparison entirely and silently
skipping computed-column expansion (the column hid behind the alias).

Parse user fragments as predicates (`SELECT * WHERE {expr}`) at every parse
site — the parser cache, measure-filter CASE WHEN generation, computed-column
expansion, and measure-filter/segment column qualification. For plain
non-condition expressions the column set is identical, so this is a no-op
everywhere except the T-SQL alias case it fixes.

Add cross-dialect regression tests (tsql, postgres, snowflake, bigquery)
locking equality filters/segments to comparison shape and confirming `= 'x'`
now matches `IN ('x')` on T-SQL.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Shorten T-SQL predicate comments

* docs(sl): tighten T-SQL predicate docstrings and AGENTS docstring rule

Trim the parser and regression-test docstrings to the 1-3 line bar and
extend the AGENTS.md comment guidance to cover docstrings explicitly.

* refactor(sl): route all filter parsing through parse_predicate

Consolidate the predicate-context parse into a single parse_predicate
helper and route every filter-parsing call site through it: measure
CASE-WHEN filters, segments, computed-column-in-filter, the
aggregate-locality HAVING rewrite, and the planner OR-mixing /
top-level-AND split. The locality and split paths still parsed user
filters in projection context, so a named-measure equality filter
compiled to `0 AS measure` on T-SQL. Add a locality regression test
covering the HAVING rewrite path.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Andrey Avtomonov <andreybavt@gmail.com>
2026-06-19 08:47:44 +00:00
..
__init__.py rename klo to ktx 2026-05-10 23:51:24 +02:00
conftest.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_aggregate_locality.py docs: standardize fanout terminology (#218) 2026-05-25 11:09:33 -04:00
test_cli.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_computed_columns.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_corner_case_regressions.py feat(context): add warehouse verification tools (#46) 2026-05-13 13:43:23 +02:00
test_coverage_gaps.py docs: standardize fanout terminology (#218) 2026-05-25 11:09:33 -04:00
test_duplicate_check.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_engine.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_generator.py docs: standardize fanout terminology (#218) 2026-05-25 11:09:33 -04:00
test_graph.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_loader.py fix(context): merge overlay columns onto manifest columns by name (#94) 2026-05-15 02:11:04 +02:00
test_manifest.py fix(context): merge overlay columns onto manifest columns by name (#94) 2026-05-15 02:11:04 +02:00
test_models.py Normalize semantic layer descriptions 2026-05-11 00:31:15 -07:00
test_parser.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_planner.py docs: standardize fanout terminology (#218) 2026-05-25 11:09:33 -04:00
test_segments.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_snowflake.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_sql_join_coverage.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_table_identifier_parser.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_tpch.py rename klo to ktx 2026-05-10 23:51:24 +02:00
test_tsql_filter_alias_regression.py fix(sl): parse user filter expressions as predicates, not projections (#307) 2026-06-19 08:47:44 +00:00
test_validator.py Improve schema setup and Notion ingest UX (#14) 2026-05-12 22:56:58 +02:00