Skip to content

Commit

Permalink
function support added
Browse files Browse the repository at this point in the history
  • Loading branch information
antonchirikalov committed Aug 16, 2022
1 parent 255357c commit e1cb108
Show file tree
Hide file tree
Showing 13 changed files with 896 additions and 321 deletions.
7 changes: 6 additions & 1 deletion processor/stream_processor/Sql.g4
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ aggregationColumns


column
: IDENTIFIER
: IDENTIFIER #identifierCol
| (K_UPPER | K_LOWER ) L_BRACKET IDENTIFIER R_BRACKET #functionCol
;


whereStatement
: K_WHERE expr #whereStmt
;
Expand Down Expand Up @@ -113,6 +115,9 @@ K_MAX : M A X;
K_AVG : A V G;
K_TRUE : T R U E;
K_FALSE : F A L S E;
// function
K_UPPER : U P P E R;
K_LOWER : L O W E R;

IDENTIFIER
: '"' (~'"' | '""')* '"'
Expand Down
6 changes: 5 additions & 1 deletion processor/stream_processor/parser/Sql.interp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ null
null
null
null
null
null
'*'

token symbolic names:
Expand Down Expand Up @@ -77,6 +79,8 @@ K_MAX
K_AVG
K_TRUE
K_FALSE
K_UPPER
K_LOWER
IDENTIFIER
NUMERIC_LITERAL
STRING_LITERAL
Expand All @@ -99,4 +103,4 @@ groupBy


atn:
[4, 1, 39, 125, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 33, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 41, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 49, 8, 1, 1, 1, 1, 1, 1, 1, 3, 1, 54, 8, 1, 1, 2, 1, 2, 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, 38, 40, 3, 4, 2, 0, 39, 41, 3, 12, 6, 0, 40, 39, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 43, 5, 6, 0, 0, 43, 54, 1, 0, 0, 0, 44, 45, 5, 8, 0, 0, 45, 46, 3, 8, 4, 0, 46, 48, 3, 4, 2, 0, 47, 49, 3, 12, 6, 0, 48, 47, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 51, 3, 24, 12, 0, 51, 52, 5, 6, 0, 0, 52, 54, 1, 0, 0, 0, 53, 29, 1, 0, 0, 0, 53, 36, 1, 0, 0, 0, 53, 44, 1, 0, 0, 0, 54, 3, 1, 0, 0, 0, 55, 56, 5, 10, 0, 0, 56, 57, 5, 37, 0, 0, 57, 5, 1, 0, 0, 0, 58, 63, 3, 10, 5, 0, 59, 60, 5, 3, 0, 0, 60, 62, 3, 10, 5, 0, 61, 59, 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 68, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 5, 39, 0, 0, 67, 58, 1, 0, 0, 0, 67, 66, 1, 0, 0, 0, 68, 7, 1, 0, 0, 0, 69, 70, 3, 10, 5, 0, 70, 71, 5, 3, 0, 0, 71, 73, 1, 0, 0, 0, 72, 69, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 75, 7, 0, 0, 0, 75, 78, 5, 4, 0, 0, 76, 79, 3, 10, 5, 0, 77, 79, 5, 39, 0, 0, 78, 76, 1, 0, 0, 0, 78, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 81, 5, 5, 0, 0, 81, 9, 1, 0, 0, 0, 82, 83, 5, 36, 0, 0, 83, 11, 1, 0, 0, 0, 84, 85, 5, 9, 0, 0, 85, 86, 3, 14, 7, 0, 86, 13, 1, 0, 0, 0, 87, 88, 6, 7, -1, 0, 88, 100, 3, 16, 8, 0, 89, 92, 3, 18, 9, 0, 90, 92, 3, 16, 8, 0, 91, 89, 1, 0, 0, 0, 91, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 96, 7, 1, 0, 0, 94, 97, 3, 18, 9, 0, 95, 97, 3, 16, 8, 0, 96, 94, 1, 0, 0, 0, 96, 95, 1, 0, 0, 0, 97, 100, 1, 0, 0, 0, 98, 100, 3, 18, 9, 0, 99, 87, 1, 0, 0, 0, 99, 91, 1, 0, 0, 0, 99, 98, 1, 0, 0, 0, 100, 106, 1, 0, 0, 0, 101, 102, 10, 2, 0, 0, 102, 103, 7, 1, 0, 0, 103, 105, 3, 14, 7, 3, 104, 101, 1, 0, 0, 0, 105, 108, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 15, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 110, 5, 36, 0, 0, 110, 111, 3, 20, 10, 0, 111, 112, 3, 22, 11, 0, 112, 17, 1, 0, 0, 0, 113, 114, 5, 4, 0, 0, 114, 115, 3, 14, 7, 0, 115, 116, 5, 5, 0, 0, 116, 19, 1, 0, 0, 0, 117, 118, 7, 2, 0, 0, 118, 21, 1, 0, 0, 0, 119, 120, 7, 3, 0, 0, 120, 23, 1, 0, 0, 0, 121, 122, 5, 11, 0, 0, 122, 123, 3, 10, 5, 0, 123, 25, 1, 0, 0, 0, 12, 32, 40, 48, 53, 63, 67, 72, 78, 91, 96, 99, 106]
[4, 1, 41, 130, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 33, 8, 1, 1, 1,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0, 0, 0, 29, 30, 5, 8, 0, 0, 30, 32, 3, 6, 3, 0, 31, 33, 3, 12, 6, 0, 32, 31, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 5, 6, 0, 0, 35, 54, 1, 0, 0, 0, 36, 37, 5, 8, 0, 0, 37, 38, 3, 8, 4, 0, 38, 40, 3, 4, 2, 0, 39, 41, 3, 12, 6, 0, 40, 39, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 43, 5, 6, 0, 0, 43, 54, 1, 0, 0, 0, 44, 45, 5, 8, 0, 0, 45, 46, 3, 8, 4, 0, 46, 48, 3, 4, 2, 0, 47, 49, 3, 12, 6, 0, 48, 47, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 51, 3, 24, 12, 0, 51, 52, 5, 6, 0, 0, 52, 54, 1, 0, 0, 0, 53, 29, 1, 0, 0, 0, 53, 36, 1, 0, 0, 0, 53, 44, 1, 0, 0, 0, 54, 3, 1, 0, 0, 0, 55, 56, 5, 10, 0, 0, 56, 57, 5, 39, 0, 0, 57, 5, 1, 0, 0, 0, 58, 63, 3, 10, 5, 0, 59, 60, 5, 3, 0, 0, 60, 62, 3, 10, 5, 0, 61, 59, 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 68, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 5, 41, 0, 0, 67, 58, 1, 0, 0, 0, 67, 66, 1, 0, 0, 0, 68, 7, 1, 0, 0, 0, 69, 70, 3, 10, 5, 0, 70, 71, 5, 3, 0, 0, 71, 73, 1, 0, 0, 0, 72, 69, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 75, 7, 0, 0, 0, 75, 78, 5, 4, 0, 0, 76, 79, 3, 10, 5, 0, 77, 79, 5, 41, 0, 0, 78, 76, 1, 0, 0, 0, 78, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 81, 5, 5, 0, 0, 81, 9, 1, 0, 0, 0, 82, 88, 5, 38, 0, 0, 83, 84, 7, 1, 0, 0, 84, 85, 5, 4, 0, 0, 85, 86, 5, 38, 0, 0, 86, 88, 5, 5, 0, 0, 87, 82, 1, 0, 0, 0, 87, 83, 1, 0, 0, 0, 88, 11, 1, 0, 0, 0, 89, 90, 5, 9, 0, 0, 90, 91, 3, 14, 7, 0, 91, 13, 1, 0, 0, 0, 92, 93, 6, 7, -1, 0, 93, 105, 3, 16, 8, 0, 94, 97, 3, 18, 9, 0, 95, 97, 3, 16, 8, 0, 96, 94, 1, 0, 0, 0, 96, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 101, 7, 2, 0, 0, 99, 102, 3, 18, 9, 0, 100, 102, 3, 16, 8, 0, 101, 99, 1, 0, 0, 0, 101, 100, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 105, 3, 18, 9, 0, 104, 92, 1, 0, 0, 0, 104, 96, 1, 0, 0, 0, 104, 103, 1, 0, 0, 0, 105, 111, 1, 0, 0, 0, 106, 107, 10, 2, 0, 0, 107, 108, 7, 2, 0, 0, 108, 110, 3, 14, 7, 3, 109, 106, 1, 0, 0, 0, 110, 113, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 15, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 114, 115, 5, 38, 0, 0, 115, 116, 3, 20, 10, 0, 116, 117, 3, 22, 11, 0, 117, 17, 1, 0, 0, 0, 118, 119, 5, 4, 0, 0, 119, 120, 3, 14, 7, 0, 120, 121, 5, 5, 0, 0, 121, 19, 1, 0, 0, 0, 122, 123, 7, 3, 0, 0, 123, 21, 1, 0, 0, 0, 124, 125, 7, 4, 0, 0, 125, 23, 1, 0, 0, 0, 126, 127, 5, 11, 0, 0, 127, 128, 3, 10, 5, 0, 128, 25, 1, 0, 0, 0, 13, 32, 40, 48, 53, 63, 67, 72, 78, 87, 96, 101, 104, 111]
12 changes: 7 additions & 5 deletions processor/stream_processor/parser/Sql.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ K_MAX=32
K_AVG=33
K_TRUE=34
K_FALSE=35
IDENTIFIER=36
NUMERIC_LITERAL=37
STRING_LITERAL=38
STAR=39
K_UPPER=36
K_LOWER=37
IDENTIFIER=38
NUMERIC_LITERAL=39
STRING_LITERAL=40
STAR=41
','=3
'('=4
')'=5
';'=6
'='=17
'>'=18
'<'=19
'*'=39
'*'=41
Loading

0 comments on commit e1cb108

Please sign in to comment.