Skip to content

Commit cd6db25

Browse files
committed
Support CORRESPONDING keyword on Trino set operations
Fixes #934
1 parent 6291ebb commit cd6db25

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/languages/trino/trino.formatter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ const tabularOnelineClauses = expandPhrases([
105105
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L231-L235
106106
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L288-L291
107107
const reservedSetOperations = expandPhrases([
108-
'UNION [ALL | DISTINCT]',
109-
'EXCEPT [ALL | DISTINCT]',
110-
'INTERSECT [ALL | DISTINCT]',
108+
'UNION [ALL | DISTINCT] [CORRESPONDING]',
109+
'EXCEPT [ALL | DISTINCT] [CORRESPONDING]',
110+
'INTERSECT [ALL | DISTINCT] [CORRESPONDING]',
111111
]);
112112

113113
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L299-L313

test/trino.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import supportsComments from './features/comments.js';
1616
import supportsCommentOn from './features/commentOn.js';
1717
import supportsIdentifiers from './features/identifiers.js';
1818
import supportsParams from './options/param.js';
19-
import supportsSetOperations from './features/setOperations.js';
19+
import supportsSetOperations, { standardSetOperations } from './features/setOperations.js';
2020
import supportsWindow from './features/window.js';
2121
import supportsLimiting from './features/limiting.js';
2222
import supportsInsertInto from './features/insertInto.js';
@@ -58,7 +58,10 @@ describe('TrinoFormatter', () => {
5858
supportsArrayLiterals(format, { withArrayPrefix: true });
5959
supportsArrayAndMapAccessors(format);
6060
supportsJoin(format);
61-
supportsSetOperations(format);
61+
supportsSetOperations(format, [
62+
...standardSetOperations,
63+
...standardSetOperations.map(op => `${op} CORRESPONDING`),
64+
]);
6265
supportsParams(format, { positional: true });
6366
supportsWindow(format);
6467
supportsLimiting(format, { limit: true, offset: true, fetchFirst: true, fetchNext: true });

0 commit comments

Comments
 (0)