Skip to content

fix(trino): update timezone grammar to avoid ambiguity #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/grammar/trino/TrinoSql.g4
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,15 @@ normalForm
;

type
: KW_ROW '(' rowField (',' rowField)* ')' # rowType
| KW_INTERVAL from=intervalField (KW_TO to=intervalField)? # intervalType
| base=KW_TIMESTAMP ('(' precision= typeParameter ')')? (KW_WITHOUT KW_TIME KW_ZONE)? # dateTimeType
| base=KW_TIMESTAMP ('(' precision= typeParameter ')')? KW_WITH KW_TIME KW_ZONE # dateTimeType
| base=KW_TIME ('(' precision= typeParameter ')')? (KW_WITHOUT KW_TIME KW_ZONE)? # dateTimeType
| base=KW_TIME ('(' precision= typeParameter ')')? KW_WITH KW_TIME KW_ZONE # dateTimeType
| KW_DOUBLE KW_PRECISION # doublePrecisionType
| KW_ARRAY '<' type '>' # legacyArrayType
| KW_MAP '<' keyType=type ',' valueType=type '>' # legacyMapType
| type KW_ARRAY ('[' INTEGER_VALUE ']')? # arrayType
| identifier ('(' typeParameter (',' typeParameter)* ')')? # genericType
: KW_ROW '(' rowField (',' rowField)* ')' # rowType
| KW_INTERVAL from=intervalField (KW_TO to=intervalField)? # intervalType
| base=KW_TIMESTAMP ('(' precision= typeParameter ')')? ((KW_WITH | KW_WITHOUT) KW_TIME KW_ZONE)? # dateTimeType
| base=KW_TIME ('(' precision= typeParameter ')')? ((KW_WITH | KW_WITHOUT) KW_TIME KW_ZONE)? # timeType
| KW_DOUBLE KW_PRECISION # doublePrecisionType
| KW_ARRAY '<' type '>' # legacyArrayType
| KW_MAP '<' keyType=type ',' valueType=type '>' # legacyMapType
| type KW_ARRAY ('[' INTEGER_VALUE ']')? # arrayType
| identifier ('(' typeParameter (',' typeParameter)* ')')? # genericType
;

rowField
Expand Down
2 changes: 1 addition & 1 deletion src/lib/trino/TrinoSql.interp

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/lib/trino/TrinoSqlListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ import { RowTypeContext } from "./TrinoSqlParser.js";
import { IntervalTypeContext } from "./TrinoSqlParser.js";
import { ArrayTypeContext } from "./TrinoSqlParser.js";
import { DoublePrecisionTypeContext } from "./TrinoSqlParser.js";
import { TimeTypeContext } from "./TrinoSqlParser.js";
import { LegacyArrayTypeContext } from "./TrinoSqlParser.js";
import { GenericTypeContext } from "./TrinoSqlParser.js";
import { DateTimeTypeContext } from "./TrinoSqlParser.js";
Expand Down Expand Up @@ -3356,6 +3357,18 @@ export class TrinoSqlListener implements ParseTreeListener {
* @param ctx the parse tree
*/
exitDoublePrecisionType?: (ctx: DoublePrecisionTypeContext) => void;
/**
* Enter a parse tree produced by the `timeType`
* labeled alternative in `TrinoSqlParser.type`.
* @param ctx the parse tree
*/
enterTimeType?: (ctx: TimeTypeContext) => void;
/**
* Exit a parse tree produced by the `timeType`
* labeled alternative in `TrinoSqlParser.type`.
* @param ctx the parse tree
*/
exitTimeType?: (ctx: TimeTypeContext) => void;
/**
* Enter a parse tree produced by the `legacyArrayType`
* labeled alternative in `TrinoSqlParser.type`.
Expand Down
Loading