Repository navigation
Conversation
Align || precedence below + and - to match sqlglot and PostgreSQL, allow ORDER as a non-reserved identifier, add unary and concat precedence tests, parse compliance/**/*.ossie.yaml models, and consolidate grammar Ruff and Makefile configuration with apache#682.
orca-review-bot
left a comment
There was a problem hiding this comment.
Looks good to me. make test-grammar passes locally (12 passed). The || move matches sqlglot, and ORDER as a non-reserved word doesn't break the existing window or WITHIN GROUP fixtures.
Checked and fine: EXISTS_IN() with no arguments matches how expression_language.md:151 refers to it (no signature given), and the #657 review asked for that fixture. The README's REQUIRED claim for || checks out (expression_language.md:459).
Follow-up (not this PR): could we add || to the Operator Precedence list in core-spec/expression_language.md, between Addition/Subtraction and Comparison? Then the grammar comment can drop the "spec does not say" caveat.
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| schema.dataset."Field" | ||
| date | ||
| first | ||
| SUM(order.sales) / COUNT(DISTINCT order.customer_id) |
There was a problem hiding this comment.
nit: this only covers order at the top level. Could we also add SUM(x) OVER (ORDER BY order), so we know the identifier still works right after the ORDER BY keyword?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| assert kind(add.valueExpr(1)) == "MultiplicativeValue" | ||
|
|
||
|
|
||
| def test_addition_binds_tighter_than_concat(ossie): |
There was a problem hiding this comment.
nit: could we add the mirror case a + b || c here too, asserting ConcatValue with an AdditiveValue on the left? Then both sides of the new level are pinned.
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
|
|
||
| .PHONY: test-grammar | ||
| test-grammar: DEPENDENCIES := $(UV) java | ||
| test-grammar: check-dependencies ## Run ANTLR4 expression grammar tests |
There was a problem hiding this comment.
nit: make test doesn't run this target, which makes sense since java is optional. Could the help text say "(needs java; not part of make test)" so people don't assume it's covered?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
kayemkim
left a comment
There was a problem hiding this comment.
With order, the grammar lets 14 words that SQL:2023 reserves be an unquoted name (group, date, time, row, filter, ...), out of 39 reserved among its 50 keywords (per the SQL Key Words appendix of the PostgreSQL docs), and it refuses the other 25 plus ilike and try_cast. expression_language.md says identifiers "MUST be valid names and follow ANSI SQL naming", and validate.py is looser again: it refuses 12 of the 50 and takes case, end, from and null as dataset names.
The rule in the comment above nonReservedWord, reserved only where a word would make an expression ambiguous, reads like the right one to me. It is in neither the spec nor the README's "Where the grammar goes beyond the spec text" list, so a reader of the spec cannot tell which names need quotes. A line in that README section would cover it here, and I can take the sentence for the Identifiers section to dev@.
Summary
Addresses the non-blocking review comments and tooling follow-ups from #657:
||precedence & documentation: Parse||(# concatValue) below+and-(# additiveValue) soa || b + cparses asa || (b + c), matchingsqlglot(validation/validate.py) and PostgreSQL. Clarify incore-spec/grammar/README.mdthat||is aREQUIREDoperator inexpression_language.mdwhose precedence is not yet stated in the spec.ORDERinnonReservedWord: AllowORDERas an unquoted identifier so the portable example incore-spec/spec.md(SUM(order.sales) / COUNT(DISTINCT order.customer_id)) parses cleanly, and pin it alongsideEXISTS_IN()incompliance/expressions/valid.txt.test_unary_binds_tighter_than_multiplication_and_additionandtest_addition_binds_tighter_than_concatincore-spec/grammar/tests/test_expression_grammar.py.test_compliance_models_parseto parse all portable expressions incompliance/**/*.ossie.yaml(and triggerGrammar CIwhencompliance/**/*.ossie.yamlchanges).core-spec/grammar/ruff.tomlinto the rootruff.tomland formatcore-spec/grammar/tests/conftest.pyaccordingly..editorconfig.make test-grammartarget and includecore-spec/grammarinmake clean.astral-sh/setup-uvin.github/workflows/grammar-ci.ymltov10.3.3.Related Issues
Follow-up to #657.
Checklist
Specification
core-spec/and follow the existing structuredocs/spec_changes.mdrecords rationale, compatibility and migration impact, or the PR explains why no entry is needed (reference grammar follow-up only; no normative spec change)Ontology
ontology/are consistent with spec changesConverters
Validation
validation/are updated if the spec changedDocumentation
docs/is updated to reflect any user-facing changesCONTRIBUTING.mdis updated if the contribution process changedExamples
examples/are added or updated for any new spec constructsTests
pytest/ CI green)Compliance
NOTICEand/orLICENSEhave been updated per ASF policy