Skip to content

Fix Ossie logical expressions and aggregate grains in Python - #402

Merged
nicosuave merged 3 commits into
ossie-source-contractfrom
ossie-python-runtime
Oct 2, 2026
Merged

nicosuave merged 3 commits into
ossie-source-contractfrom
ossie-python-runtime

Conversation

@nicosuave

@nicosuave nicosuave commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Ossie metrics could bind to physical columns instead of declared logical fields, lose computed join keys, or change existing totals when another metric was selected. This fixes the Python execution path and adds OSSIE_SQL_2026 parsing and target lowering.

Logical names now bind before physical-column fallback, with exact quoted identities, normalized regular identifiers, and validated metric dependencies. Aggregate leaves retain independent entity or joined-row populations; computed relationship keys and imported window fields keep their intended semantics. The portable-expression corpus supplies independently expected results for required function families.

Local focused Python execution/export validation: 315 passed. Ruff, formatting, and whitespace checks passed. Python-specific tests select that engine explicitly; the later shared corpus exercises every case through Python, public Rust without fallback, and native Rust. Exact BigQuery percentiles and unsupported target combinations return explicit diagnostics.

@nicosuave
nicosuave added this pull request to stack #404 October 2, 2026 13:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T13:19:15.599285Z a6083fd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@nicosuave nicosuave changed the title Preserve Ossie logical expressions and aggregate grains in Python Fix Ossie logical expressions and aggregate grains in Python Oct 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6083fd170

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

def extract(value: exp.Expression, unit: str) -> exp.Expression:
return exp.Extract(this=exp.Var(this=unit), expression=value.copy())

if part in {"YEAR", "MONTH", "QUARTER"}:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve boundary semantics for PostgreSQL sub-day DATEDIFF

Implement the boundary-counting rewrite for units beyond year/month/quarter. For example, DATEDIFF(hour, TIMESTAMP '2024-01-01 10:59:00', TIMESTAMP '2024-01-01 11:01:00') must return 1 under the portable Snowflake-style contract, but the unhandled PostgreSQL path falls through to SQLGlot's elapsed-interval translation and returns 0. This silently corrupts PostgreSQL results for hour/minute/second differences that cross a calendar boundary without spanning a full unit.

Useful? React with 👍 / 👎.

Comment on lines +152 to +153
if target not in {"duckdb", "postgres", "snowflake", "bigquery", "databricks"}:
raise ValueError(f"Unsupported OSSIE_SQL_2026 target {target_dialect!r}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow portable expressions to target supported Spark SQL

Include Spark in portable lowering or fall back to a provided ANSI variant. spark is already accepted by the Ossie lowering parser and is a supported Sidemantic database dialect, but any field containing an OSSIE_SQL_2026 variant is selected first and then rejected by this allowlist; even a document that also supplies a valid ANSI_SQL expression becomes non-executable for Spark.

Useful? React with 👍 / 👎.

@nicosuave
nicosuave force-pushed the ossie-python-runtime branch from a6083fd to c48fb07 Compare October 2, 2026 13:54
@nicosuave
nicosuave merged commit 79e917b into main Oct 2, 2026
28 of 54 checks passed
@nicosuave
nicosuave deleted the ossie-python-runtime branch October 2, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant