Add TrinoDialect - #2485
Open
rexminnis wants to merge 1 commit into
Open
Conversation
Trino (the SQL engine that descends from Presto) follows the standard closely, and most of what it needs is already an opt-in hook: double-quoted identifiers only, FILTER on aggregates, GROUP BY expressions and grouping sets, lambdas, MATCH_RECOGNIZE, table versioning, parenthesized EXPLAIN options, named table-function arguments with =>, and COMMENT ON. The test corpus covers the constructs a Trino user writes daily. Not covered yet: the FOR prefix on TIMESTAMP/VERSION AS OF (time travel), ROW types with named fields, and inline WITH FUNCTION routines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
TrinoDialectfor Trino, the distributed SQL engine that descends from Presto, and registers it as"trino"indialect_from_str.Trino follows the SQL standard closely, so almost everything it needs is an existing opt-in hook. The dialect turns on:
FILTER (WHERE ...)on aggregates — https://trino.io/docs/current/sql/select.html#filterGROUP BYexpressions,GROUPING SETS,CUBE,ROLLUP— https://trino.io/docs/current/sql/select.html#group-by-clauseMATCH_RECOGNIZE— https://trino.io/docs/current/sql/match-recognize.htmlEXPLAINoptions such asEXPLAIN (TYPE IO, FORMAT JSON)— https://trino.io/docs/current/sql/explain.html=>named arguments to table functions — https://trino.io/docs/current/functions/table.htmlCOMMENT ON— https://trino.io/docs/current/sql/comment.htmltests/sqlparser_trino.rscarries a corpus of 27 statements a Trino user writes daily (typed literals,UNNEST WITH ORDINALITY,TABLESAMPLE,LISTAGG ... WITHIN GROUP, JSON path functions,AT TIME ZONE,FETCH FIRST,SHOW/DESCRIBE, ...), including a negative test that backquoted identifiers are rejected.Not covered here, on purpose, each a small follow-up:
FORprefix onTIMESTAMP AS OF/VERSION AS OF(a stacked PR follows this one)ROW(name type, ...)types with named fields, which currently parse as a flat list on every dialectWITH FUNCTION ... RETURNroutines