Skip to content

feat(core-spec): register POSTGRES and REDSHIFT as dialects - #598

Open
403pagelabs wants to merge 2 commits into
apache:mainfrom
403pagelabs:dialect-postgres-redshift
Open

403pagelabs wants to merge 2 commits into
apache:mainfrom
403pagelabs:dialect-postgres-redshift

Conversation

@403pagelabs

@403pagelabs 403pagelabs commented Oct 16, 2026 •

Copy link
Copy Markdown

sqlglot parses PostgreSQL and Amazon Redshift, yet the Dialect enum has no member for either. A semantic model generated for them has to label its expressions ANSI_SQL. The validator then parses the body with the wrong grammar and a converter cannot tell the expression apart from portable SQL.

Change

Same pattern as HOLISTICS_AQL in #538:

  • core-spec/ossie-schema.json: POSTGRES and REDSHIFT in $defs.Dialect.enum, the two rows in spec.md, and spec.yaml regenerated with scripts/generate-spec-types.py --apply
  • python/src/ossie/models.py: the two OssieDialect members
  • validation/validate.py: both map to their sqlglot dialect, so they are parsed rather than skipped. Tests cover the map entries, the Postgres regular-expression match ~ validating under each dialect with an ANSI_SQL control that rejects it, and an unparseable body reported under each
  • converters/hex: both exhaustive dialect maps (Hex names both dialects and its vendored sqlglot has both), the parametrised test and the CLI choices snapshot
  • converters/holistics: SQLGLOT_DIALECT in sqlrefs.py, which mirrors the validator's map and feeds the --sql-dialect choices, and the enum list docs/limitations.md quotes

Impact on existing implementations

The change is additive and no existing value changes meaning. A consumer that switches over the whole enum, as the Hex converter does with assert_never, gains two cases. The converters in this repository are handled here.

Why

I maintain GASP, a SaaS metrics standard, and generate its Ossie ontology, semantic model and mapping in four dialects (https://gaspwiki.com/downloads/ossie/). The Snowflake, BigQuery and Databricks sources carry their dialect. The Postgres and Redshift sources travel in a custom extension today because the enum has no value for them.

Checks run locally: validation (205), the Python package (174), the Hex converter (232 tests, ruff, ty and format), generate-spec-types.py --check, the four example validations and dev/check-license.

sqlglot parses PostgreSQL and Amazon Redshift, yet the Dialect enum has
no member for either. A semantic model generated for them has to label
its expressions ANSI_SQL. The validator then parses the body with the
wrong grammar and a converter cannot tell the expression apart from
portable SQL.

Same pattern as HOLISTICS_AQL in apache#538: the schema enum, spec.md and the
generated spec.yaml, the Python OssieDialect enum, the validator's
sqlglot map with tests for a Postgres cast and for an unparseable body,
the Hex converter's exhaustive dialect maps (Hex names both dialects)
and its CLI choices snapshot.

I maintain GASP, a SaaS metrics standard, and generate its Ossie model
in four dialects (https://gaspwiki.com/downloads/ossie/). The Postgres
and Redshift sources travel in a custom extension today because the
enum has no value for them.
@github-actions

Copy link
Copy Markdown

Thank you for your first contribution to Apache Ossie (incubating)!

A committer will review your PR. In the meantime, please ensure:

  • All CI checks pass
  • ASF license headers are present on new source files
  • Tests cover new functionality

No ICLA is required to contribute. If you are elected as a committer in the future, you will need an Individual Contributor License Agreement (ICLA) on file with the ASF.

Questions? Ask in the PR comments or join us on Slack.

We appreciate your contribution!

Comment thread validation/validate.py
Comment thread validation/tests/test_validate.py
…y operator

Requested in review on apache#598. The Holistics converter keeps SQLGLOT_DIALECT
in sqlrefs.py, which mirrors the validator's DIALECT_MAP and feeds the
--sql-dialect choices, so until now neither dialect could be selected and
a POSTGRES body fell through to sqlglot's default reader.

The validator test now uses the regular-expression match `~`, which the
default reader rejects, with an ANSI_SQL control, so it shows the
dialect's own reader is used. Both the `::` cast it replaces and ILIKE
parse under the default reader.
@403pagelabs
403pagelabs requested a review from jbonofre October 16, 2026 18:28
@403pagelabs

Copy link
Copy Markdown
Author

I replied on dev@ to Chris's portability question: https://lists.apache.org/thread/46h1cr804mn6m4r35vrqn1tkdhrjxm7m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants