Skip to content

Commit e685e9a

Browse files
authored
Merge pull request #4 from hackolade/feature/snowflake-colon-support
Add support for snowflake colon notation
2 parents 51674eb + daf66bf commit e685e9a

11 files changed

Lines changed: 5835 additions & 5589 deletions

grammars/SQLSelectLexer.g4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@ BRACKET_QUOTED_TEXT: (
461461
)+
462462
;
463463

464+
BRACKET_QUOTED_NUMBER: (
465+
OPEN_BRACKET_SYMBOL INT_NUMBER CLOSE_BRACKET_SYMBOL
466+
)+
467+
;
468+
464469
CURLY_BRACES_QUOTED_TEXT: (
465470
OPEN_DOUBLE_CURLY_SYMBOL .*? CLOSE_DOUBLE_CURLY_SYMBOL
466471
)+

grammars/SQLSelectParser.g4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ selectItemList: (selectItem | MULT_OPERATOR) (COMMA_SYMBOL selectItem)*
248248
;
249249

250250
selectItem:
251-
qualifiedIdentifier selectAlias?
251+
(qualifiedIdentifier | jsonPathIdentifier) selectAlias?
252252
| expr selectAlias?
253253
;
254254

@@ -995,7 +995,7 @@ identifier:
995995
| identifierKeyword
996996
;
997997

998-
identifierList:
998+
identifierList:
999999
identifier (COMMA_SYMBOL identifier)*
10001000
;
10011001

@@ -1007,6 +1007,10 @@ qualifiedIdentifier:
10071007
identifier (DOT_SYMBOL identifier)* (DOT_SYMBOL MULT_OPERATOR)?
10081008
;
10091009

1010+
jsonPathIdentifier:
1011+
qualifiedIdentifier COLON_SYMBOL identifier (((DOT_SYMBOL | COLON_SYMBOL) identifier) | BRACKET_QUOTED_TEXT)* (CAST_COLON_SYMBOL dataType)?
1012+
;
1013+
10101014
dotIdentifier:
10111015
DOT_SYMBOL identifier
10121016
;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hackolade/sql-select-statement-parser",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "",
55
"main": "index.js",
66
"author": "Hackolade",

parser/SQLSelectLexer.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

parser/SQLSelectLexer.js

Lines changed: 2064 additions & 2054 deletions
Large diffs are not rendered by default.

parser/SQLSelectLexer.tokens

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,14 @@ BACK_TICK_QUOTED_ID=350
351351
DOUBLE_QUOTED_TEXT=351
352352
SINGLE_QUOTED_TEXT=352
353353
BRACKET_QUOTED_TEXT=353
354-
CURLY_BRACES_QUOTED_TEXT=354
355-
VERSION_COMMENT_START=355
356-
MYSQL_COMMENT_START=356
357-
VERSION_COMMENT_END=357
358-
BLOCK_COMMENT=358
359-
POUND_COMMENT=359
360-
DASHDASH_COMMENT=360
354+
BRACKET_QUOTED_NUMBER=354
355+
CURLY_BRACES_QUOTED_TEXT=355
356+
VERSION_COMMENT_START=356
357+
MYSQL_COMMENT_START=357
358+
VERSION_COMMENT_END=358
359+
BLOCK_COMMENT=359
360+
POUND_COMMENT=360
361+
DASHDASH_COMMENT=361
361362
'='=1
362363
':='=2
363364
'<=>'=3
@@ -399,5 +400,5 @@ DASHDASH_COMMENT=360
399400
'\\N'=41
400401
'?'=42
401402
'::'=43
402-
'/*!'=356
403-
'*/'=357
403+
'/*!'=357
404+
'*/'=358

parser/SQLSelectParser.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

parser/SQLSelectParser.js

Lines changed: 3709 additions & 3510 deletions
Large diffs are not rendered by default.

parser/SQLSelectParser.tokens

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,14 @@ BACK_TICK_QUOTED_ID=350
351351
DOUBLE_QUOTED_TEXT=351
352352
SINGLE_QUOTED_TEXT=352
353353
BRACKET_QUOTED_TEXT=353
354-
CURLY_BRACES_QUOTED_TEXT=354
355-
VERSION_COMMENT_START=355
356-
MYSQL_COMMENT_START=356
357-
VERSION_COMMENT_END=357
358-
BLOCK_COMMENT=358
359-
POUND_COMMENT=359
360-
DASHDASH_COMMENT=360
354+
BRACKET_QUOTED_NUMBER=354
355+
CURLY_BRACES_QUOTED_TEXT=355
356+
VERSION_COMMENT_START=356
357+
MYSQL_COMMENT_START=357
358+
VERSION_COMMENT_END=358
359+
BLOCK_COMMENT=359
360+
POUND_COMMENT=360
361+
DASHDASH_COMMENT=361
361362
'='=1
362363
':='=2
363364
'<=>'=3
@@ -399,5 +400,5 @@ DASHDASH_COMMENT=360
399400
'\\N'=41
400401
'?'=42
401402
'::'=43
402-
'/*!'=356
403-
'*/'=357
403+
'/*!'=357
404+
'*/'=358

parser/SQLSelectParserListener.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,15 @@ class SQLSelectParserListener extends antlr4.tree.ParseTreeListener {
13541354
}
13551355

13561356

1357+
// Enter a parse tree produced by SQLSelectParser#jsonPathIdentifier.
1358+
enterJsonPathIdentifier(ctx) {
1359+
}
1360+
1361+
// Exit a parse tree produced by SQLSelectParser#jsonPathIdentifier.
1362+
exitJsonPathIdentifier(ctx) {
1363+
}
1364+
1365+
13571366
// Enter a parse tree produced by SQLSelectParser#dotIdentifier.
13581367
enterDotIdentifier(ctx) {
13591368
}

0 commit comments

Comments
 (0)