You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add test for keywword
(cherry picked from commit 9d08003)
* Refacto expr & id_ (WIP)
* Add test for id_
* Fix wrong level of binary, ternary..function_call
Copy file name to clipboardExpand all lines: sql/snowflake/SnowflakeParser.g4
+58-38Lines changed: 58 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -2572,6 +2572,7 @@ object_type_plural
2572
2572
| STAGES
2573
2573
| STREAMS
2574
2574
| TASKS
2575
+
| ALERTS
2575
2576
;
2576
2577
2577
2578
// drop commands
@@ -3363,24 +3364,26 @@ id_fn
3363
3364
;
3364
3365
3365
3366
id_
3367
+
//id_ is used for object name. Snowflake is very permissive
3368
+
//so we could use nearly all keyword as object name (table, column etc..)
3366
3369
: ID
3367
3370
| ID2
3368
3371
| DOUBLE_QUOTE_ID
3369
3372
| DOUBLE_QUOTE_BLANK
3370
3373
| keyword
3371
3374
| non_reserved_words
3375
+
| object_type_plural
3372
3376
| data_type
3373
3377
| builtin_function
3374
-
| ALERT
3375
-
| ALERTS
3376
-
| CONDITION
3377
3378
| binary_builtin_function
3379
+
| binary_or_ternary_builtin_function
3380
+
| ternary_builtin_function
3378
3381
;
3379
3382
3380
3383
keyword
3381
-
: INT
3382
-
| BIGINT
3383
-
|STAGE
3384
+
//List here keyword (SnowSQL meaning) allowed as object name
3385
+
// Name of builtin function should be included in specifique section (ie builtin_function)
3386
+
:STAGE
3384
3387
| USER
3385
3388
| TYPE
3386
3389
| CLUSTER
@@ -3398,10 +3401,27 @@ keyword
3398
3401
| DIRECTION
3399
3402
| LENGTH
3400
3403
| LANGUAGE
3404
+
| KEY
3405
+
| ALERT
3406
+
| CONDITION
3407
+
| ROLE
3408
+
| ROW_NUMBER
3409
+
| VALUE
3410
+
| FIRST_VALUE
3411
+
| VALUES
3412
+
| TARGET_LAG
3413
+
| EMAIL
3414
+
| MAX_CONCURRENCY_LEVEL
3415
+
| WAREHOUSE_TYPE
3416
+
| TAG
3417
+
| WAREHOUSE
3418
+
| MODE
3419
+
| ACTION
3401
3420
// etc
3402
3421
;
3403
3422
3404
3423
non_reserved_words
3424
+
//List here lexer token referenced by rules which is not a keyword (SnowSQL Meaning) and allowed has object name
3405
3425
: ORGADMIN
3406
3426
| ACCOUNTADMIN
3407
3427
| SECURITYADMIN
@@ -3414,23 +3434,14 @@ non_reserved_words
3414
3434
| SOURCE
3415
3435
| PROCEDURE_NAME
3416
3436
| STATE
3417
-
| ROLE
3418
3437
| DEFINITION
3419
3438
| TIMEZONE
3420
3439
| LOCAL
3421
-
| ROW_NUMBER
3422
-
| VALUE
3423
3440
| NAME
3424
-
| TAG
3425
-
| WAREHOUSE
3426
3441
| VERSION
3427
3442
| OPTION
3428
-
| NVL2
3429
-
| FIRST_VALUE
3430
3443
| RESPECT
3431
-
| NVL
3432
3444
| RESTRICT
3433
-
| VALUES
3434
3445
| EVENT
3435
3446
| DOWNSTREAM
3436
3447
| DYNAMIC
@@ -3444,9 +3455,8 @@ non_reserved_words
3444
3455
3445
3456
builtin_function
3446
3457
// If there is a lexer entry for a function we also need to add the token here
3447
-
// as it otherwise will not be picked up by the id_ rule
3448
-
: IFF
3449
-
| SUM
3458
+
// as it otherwise will not be picked up by the id_ rule (See also derived rule below)
3459
+
: SUM
3450
3460
| AVG
3451
3461
| MIN
3452
3462
| COUNT
@@ -3459,23 +3469,19 @@ builtin_function
3459
3469
| FLATTEN
3460
3470
| SPLIT_TO_TABLE
3461
3471
| CAST
3472
+
| TRY_CAST
3462
3473
;
3463
-
3464
-
list_operator
3465
-
// lexer entry which admit a list of comma separated expr
3466
-
: CONCAT
3467
-
| CONCAT_WS
3468
-
| COALESCE
3469
-
// To complete as needed
3470
-
;
3474
+
//TODO : Split builtin between NoParam func,special_builtin_func (like CAST), unary_builtin_function and unary_or_binary_builtin_function for better AST
3471
3475
3472
3476
binary_builtin_function
3477
+
// lexer entry of function name which admit 2 parameters
3478
+
// expr rule use this
3473
3479
: ifnull = (IFNULL | NVL)
3474
3480
| GET
3475
3481
| LEFT
3476
3482
| RIGHT
3477
3483
| DATE_PART
3478
-
| to_date = (TO_DATE | DATE)
3484
+
| to_date = (TO_DATE | DATE)
3479
3485
| SPLIT
3480
3486
| NULLIF
3481
3487
| EQUAL_NULL
@@ -3484,6 +3490,8 @@ binary_builtin_function
3484
3490
;
3485
3491
3486
3492
binary_or_ternary_builtin_function
3493
+
// lexer entry of function name which admit 2 or 3 parameters
0 commit comments