Add Apache Ossie interchange conformance - #330
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf5341286e
ℹ️ 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".
| "snowflake": "snowflake", | ||
| "spark": "spark", | ||
| } |
There was a problem hiding this comment.
Support ClickHouse in the lowering dialect map
When callers lower an ANSI-only document with target_dialect="clickhouse", _sql_expression_error cannot find a configured parser and marks every field or metric invalid; strict lowering then removes all scopes. This makes Ossie lowering unusable with the ClickHouse backend that SemanticLayer explicitly supports, so map clickhouse to SQLGlot's ClickHouse dialect.
Useful? React with 👍 / 👎.
| def _classify_source(source: str, source_dialect: str | None) -> tuple[str, str] | None: | ||
| dialect = _SQLGLOT_DIALECTS.get(_normalize_dialect(source_dialect)) if source_dialect else None | ||
| try: | ||
| parsed = sqlglot.parse_one(source, read=dialect) |
There was a problem hiding this comment.
Reject multiple statements in dataset sources
For a schema-valid source such as SELECT * FROM orders; DROP TABLE orders, sqlglot.parse_one classifies only the first parsed statement while the complete original string is retained in source_text and placed into the executable Model. The expression path explicitly enforces exactly one statement, but dataset sources do not, allowing trailing SQL to enter the runtime model; parse the complete source and require exactly one statement before classifying it.
Useful? React with 👍 / 👎.
| dialect = _SQLGLOT_DIALECTS.get(_normalize_dialect(source_dialect)) if source_dialect else None | ||
| try: | ||
| parsed = sqlglot.parse_one(source, read=dialect) | ||
| except sqlglot.errors.ParseError: |
There was a problem hiding this comment.
Catch tokenizer failures during source classification
When a dataset source has malformed tokenization, such as an unterminated quoted identifier, SQLGlot raises TokenError rather than ParseError. That exception escapes _classify_source and crashes lower_ossie_document instead of producing the promised structured ossie.lowering.source_ambiguous diagnostic; catch the common SqlglotError base as the expression validator already does.
Useful? React with 👍 / 👎.
| object_pairs_hook=_unique_json_object, | ||
| parse_constant=_reject_non_finite_json_number, | ||
| ) | ||
| return yaml.load(text, Loader=_UniqueKeySafeLoader) |
There was a problem hiding this comment.
For untrusted YAML containing a compact alias-expansion graph, SafeLoader constructs shared nested objects and the later depth traversal revisits each alias occurrence without a visited-node or work budget. An acyclic graph below the 256-level limit can therefore cause exponential CPU consumption despite the 16 MiB source limit; reject aliases or enforce a bounded node/alias traversal during loading.
Useful? React with 👍 / 👎.
Stack created with GitHub Stacks CLI • Give Feedback 💬