Repository navigation
fix(validation): reject portable constructs in _parse_sql_expression and skip SELECT DISTINCT - #779
Conversation
| return None | ||
|
|
||
| interval_cls = getattr(exp, "Interval", None) | ||
| if interval_cls is not None and next(tree.find_all(interval_cls), None) is not None: |
There was a problem hiding this comment.
This also catches a field named interval. sqlglot reads interval + grace as an INTERVAL literal, so a model with fields interval and grace and a third one defined as sql: interval + grace passed before #777 and now fails with "INTERVAL is not part of OSSIE_SQL_2026". The grammar takes interval as a plain name, and grace + interval or "interval" + grace pass.
| return None, count_error | ||
| return wrapped, None | ||
|
|
||
| def accept(node: object) -> tuple[object | None, str | None]: |
There was a problem hiding this comment.
nit: _parse_sql_expression now also returns (None, error) for the rejected OSSIE_SQL_2026 constructs, but its docstring still lists only syntax, empty, multi-statement and non-expression statement errors. Could we add them there, since the downstream checks now rely on it?
christianeu-db
left a comment
There was a problem hiding this comment.
@jbonofre there are some new merge conflicts but otherwise looks good to merge
…and skip SELECT DISTINCT
e2a5ada to
5bb5e91
Compare
|
@christianeu-db I rebased and resolved the conflicts. If you can approve again, that would be great 😄 Thanks! |
Follow-up to #777:
_portable_sql_construct_errorfromvalidate_sql_expressioninto_parse_sql_expressionsoparse_treeand downstream checks (validate_metric_scoping,validate_metric_agreement,validate_metric_references,validate_field_shadowing,validate_agg_placement) treat rejectedOSSIE_SQL_2026expressions as unparsed instead of emitting secondary[Scope]/[Drift]diagnostics. This restores_parse_sql_expression's single-parse contract and aligns with feat(validation): reject queries in portable expressions and parse query sources #698.exp.Distinctnodes whose parent isexp.SelectsoSELECT DISTINCT ...stays deferred alongsideSELECT ...rather than reporting"DISTINCT requires an argument".Testing
uv run validation/test_validate.py(59 tests passed)uv run --with pytest --with pyyaml --with jsonschema --with sqlglot -m pytest validation/tests/(966 passed, 1 skipped)uv run validation/validate.py examples/tpcds_semantic_model.yamluv run validation/validate.py examples/renamed_fields.yaml