Repository navigation
feat(grammar): address PR #657 review follow-ups #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,4 +32,4 @@ indent_style = space | |
| indent_size = 4 | ||
|
|
||
| [*.g4] | ||
| indent_style = space | ||
| indent_style = space | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ DATEADD(month, -1, order_date) | |
| PI() | ||
| COALESCE(a, b, c) | ||
| ROUND(x, 2) | ||
| EXISTS_IN() | ||
|
|
||
| # Operators and predicates | ||
| first_name || ' ' || last_name | ||
|
|
@@ -88,6 +89,7 @@ dataset.field | |
| schema.dataset."Field" | ||
| date | ||
| first | ||
| SUM(order.sales) / COUNT(DISTINCT order.customer_id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this only covers 🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it. |
||
| a -- trailing comment | ||
| a + 1 /* inline */ + 2 | ||
|
|
||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
|
|
||
| REPO = Path(__file__).resolve().parents[3] | ||
| FIXTURES = REPO / "compliance" / "expressions" | ||
| COMPLIANCE = REPO / "compliance" | ||
| EXAMPLES = REPO / "examples" | ||
| PORTABLE_DIALECTS = {"ANSI_SQL", "OSSIE_SQL_2026"} | ||
|
|
||
|
|
@@ -100,10 +101,39 @@ def test_example_models_parse(ossie): | |
| assert not failures | ||
|
|
||
|
|
||
| def compliance_expressions(): | ||
| for path in sorted(COMPLIANCE.glob("**/*.ossie.yaml")): | ||
| rel = path.relative_to(REPO) | ||
| for text in portable_expressions(yaml.safe_load(path.read_text(encoding="utf-8"))): | ||
| yield f"{rel}: {text}", text | ||
|
|
||
|
|
||
| def test_compliance_models_parse(ossie): | ||
| """Every portable expression in compliance/**/*.ossie.yaml must parse.""" | ||
| found = list(compliance_expressions()) | ||
| assert found, "no expressions found in compliance/**/*.ossie.yaml" | ||
| failures = {label: e for label, text in found if (e := parse(ossie, text)[1])} | ||
| assert not failures | ||
|
|
||
|
|
||
| def kind(ctx): | ||
| return type(ctx).__name__.removesuffix("Context") | ||
|
|
||
|
|
||
| def test_unary_binds_tighter_than_multiplication_and_addition(ossie): | ||
| mul_val = top(ossie, "-a * b") | ||
| assert kind(mul_val) == "ValueOnlyExpr" | ||
| mul = mul_val.valueExpr() | ||
| assert kind(mul) == "MultiplicativeValue" | ||
| assert kind(mul.valueExpr(0)) == "UnaryValue" | ||
|
|
||
| add_val = top(ossie, "-a + b") | ||
| assert kind(add_val) == "ValueOnlyExpr" | ||
| add = add_val.valueExpr() | ||
| assert kind(add) == "AdditiveValue" | ||
| assert kind(add.valueExpr(0)) == "UnaryValue" | ||
|
|
||
|
|
||
| def test_multiplication_binds_tighter_than_addition(ossie): | ||
| value = top(ossie, "1 + 2 * 3") | ||
| assert kind(value) == "ValueOnlyExpr" | ||
|
|
@@ -112,6 +142,14 @@ def test_multiplication_binds_tighter_than_addition(ossie): | |
| assert kind(add.valueExpr(1)) == "MultiplicativeValue" | ||
|
|
||
|
|
||
| def test_addition_binds_tighter_than_concat(ossie): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could we add the mirror case 🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it. |
||
| value = top(ossie, "a || b + c") | ||
| assert kind(value) == "ValueOnlyExpr" | ||
| concat = value.valueExpr() | ||
| assert kind(concat) == "ConcatValue" | ||
| assert kind(concat.valueExpr(1)) == "AdditiveValue" | ||
|
|
||
|
|
||
| def test_not_binds_looser_than_comparison(ossie): | ||
| not_expr = top(ossie, "NOT a = b") | ||
| assert kind(not_expr) == "NotExpr" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
make testdoesn't run this target, which makes sense since java is optional. Could the help text say "(needs java; not part ofmake test)" so people don't assume it's covered?🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.