Skip to content
Open
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
7 changes: 6 additions & 1 deletion pegjs/trino.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -4178,6 +4178,12 @@ array_type
return { ...t, array: { keyword: 'array' } }
}

interval_type
= KW_INTERVAL __ f:interval_unit __ KW_TO __ t:interval_unit {
return { dataType: 'INTERVAL ' + f.toUpperCase() + ' TO ' + t.toUpperCase() };
}
/ t:KW_INTERVAL { return { dataType: t }; }

@import 'common/keyword/signedness.pegjs'
@import 'common/datatype/dialects/trino.pegjs'
@import 'common/datatype/size.pegjs'
Expand All @@ -4191,5 +4197,4 @@ array_type
@import 'common/datatype/json.pegjs'
@import 'common/datatype/geometry.pegjs'
@import 'common/datatype/serial.pegjs'
@import 'common/datatype/interval.pegjs'
@import 'common/datatype/uuid.pegjs'
14 changes: 14 additions & 0 deletions test/trino.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ describe('trino', () => {
title: "DESCRIBE statement with fully qualified name",
sql: ['DESCRIBE my_catalog.my_schema.my_table', 'DESCRIBE "my_catalog"."my_schema"."my_table"'],
},
{
title: 'CAST to INTERVAL DAY TO SECOND',
sql: [
'SELECT CAST(s.duration AS INTERVAL DAY TO SECOND) FROM t',
'SELECT CAST("s".duration AS INTERVAL DAY TO SECOND) FROM "t"',
],
},
{
title: 'CAST to INTERVAL YEAR TO MONTH',
sql: [
'SELECT CAST(s.age AS INTERVAL YEAR TO MONTH) FROM t',
'SELECT CAST("s".age AS INTERVAL YEAR TO MONTH) FROM "t"',
],
},
];
SQL_LIST.forEach((sqlInfo) => {
const { title, sql } = sqlInfo;
Expand Down