xuzifu666 commented on PR #4933: URL: https://github.com/apache/calcite/pull/4933#issuecomment-4427145032
> "DISTINCT ON" is a unique syntax of PGSQL. Would it be more appropriate to implement the parsing support for this function on the babel parser 1. Babel's only extensibility is: Configuring additional keywords, join types, and binary operators in `config.fmpp`; Adding custom parser methods (such as PostgreSQL's `BEGIN`/`COMMIT`) to `includes/*.ftl`. Babel itself does not have a separate syntax file; all SELECT-related syntax must be defined in `coreParser.jj`. 2. Consistent with QUALIFY Implementation QUALIFY is a syntax specific to Snowflake, which Calcite implements in the core: The `<QUALIFY>` token is defined in `core.Parser.jj`. The `SqlSelect` class adds a `qualify` field in the core. The Validator/SqlToRelConverter logic is in the core; `DISTINCT ON` uses the exact same pattern. 3. Conformance Controls Semantics, Not Syntax The current Parser unconditionally parses `DISTINCT ON`, but semantic validation is controlled by `SqlConformance`: // Using `LENIENT conformance` in testing `fixture().withConformance(SqlConformanceEnum.LENIENT)` This is consistent with the handling of other extensions such as QUALIFY, LATERAL, and TABLESAMPLE: the Parser is as lenient as possible, and the Validator decides whether to allow based on the dialect. so in my view:The current implementation conforms to Calcite's architectural conventions and does not require migration to Babel. For adjustments, finer-grained switches can be added to SqlConformance to control the availability of DISTINCT ON. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
