@@ -912,7 +912,7 @@ Statements Statements() #Statements: {
912
912
913
913
)
914
914
915
- (
915
+ ( LOOKAHEAD(2)
916
916
( <ST_SEMICOLON> )*
917
917
try {
918
918
(
@@ -1932,7 +1932,7 @@ Column Column() #Column :
1932
1932
data = RelObjectNames()
1933
1933
[ LOOKAHEAD(2) <K_COMMENT> tk=<S_CHAR_LITERAL> ]
1934
1934
// @todo: we better should return a SEQUENCE instead of a COLUMN
1935
- [ "." <K_NEXTVAL> { data.getNames().add("nextval"); } ]
1935
+ [ LOOKAHEAD(2) "." <K_NEXTVAL> { data.getNames().add("nextval"); } ]
1936
1936
1937
1937
[ LOOKAHEAD(2) arrayConstructor = ArrayConstructor(false) ]
1938
1938
{
@@ -4081,12 +4081,24 @@ ParenthesedExpressionList ParenthesedExpressionList():
4081
4081
4082
4082
ExpressionList SimpleExpressionList():
4083
4083
{
4084
+ ExpressionList<Column> columns;
4084
4085
ExpressionList expressions = new ExpressionList();
4085
4086
Expression expr;
4086
4087
}
4087
4088
{
4088
4089
expr=SimpleExpression() { expressions.add(expr); }
4089
- ( LOOKAHEAD(2, {!interrupted} ) "," ( LOOKAHEAD(2) expr=LambdaExpression() | expr=SimpleExpression()) { expressions.add(expr); } )*
4090
+ (
4091
+ LOOKAHEAD(2, {!interrupted} ) ","
4092
+ (
4093
+ // @todo: Check hot to avoid this expensive look ahead
4094
+ LOOKAHEAD( LambdaExpression() ) expr=LambdaExpression()
4095
+ |
4096
+ expr=SimpleExpression()
4097
+ )
4098
+ {
4099
+ expressions.add(expr);
4100
+ }
4101
+ )*
4090
4102
{
4091
4103
return expressions;
4092
4104
}
@@ -4119,6 +4131,7 @@ ParenthesedExpressionList<Column> ParenthesedColumnList():
4119
4131
4120
4132
ExpressionList ComplexExpressionList():
4121
4133
{
4134
+ ExpressionList<Column> columns;
4122
4135
ExpressionList expressions = new ExpressionList();
4123
4136
Expression expr;
4124
4137
}
@@ -4135,7 +4148,9 @@ ExpressionList ComplexExpressionList():
4135
4148
LOOKAHEAD(2, {!interrupted}) ","
4136
4149
(
4137
4150
LOOKAHEAD(2) expr=OracleNamedFunctionParameter()
4138
- | LOOKAHEAD(2) expr=LambdaExpression()
4151
+ |
4152
+ // @todo: Check hot to avoid this expensive look ahead
4153
+ LOOKAHEAD( LambdaExpression() ) expr=LambdaExpression()
4139
4154
| expr=Expression()
4140
4155
) { expressions.add(expr); }
4141
4156
)*
@@ -4378,7 +4393,7 @@ Expression BitwiseXor():
4378
4393
}
4379
4394
{
4380
4395
leftExpression=PrimaryExpression() { result = leftExpression; }
4381
- (
4396
+ ( LOOKAHEAD(2)
4382
4397
"^"
4383
4398
rightExpression=PrimaryExpression()
4384
4399
{
@@ -4514,14 +4529,27 @@ Expression PrimaryExpression() #PrimaryExpression:
4514
4529
|
4515
4530
(
4516
4531
list=ParenthesedExpressionList()
4532
+ // Mutli-Variable Lambda Expression, e. g.
4533
+ // SELECT map_filter(my_column, (k,v) -> v.my_inner_column = 'some_value')
4534
+ [ LOOKAHEAD(2) "->"
4535
+ retval = Expression()
4536
+ {
4537
+ retval = LambdaExpression.from(list, retval);
4538
+ }
4539
+ ]
4540
+
4541
+
4517
4542
{
4518
4543
if (list.size() == 1) {
4519
4544
retval = new ParenthesedExpressionList( (Expression) list.getExpressions().get(0));
4520
4545
} else {
4521
4546
retval = list;
4522
4547
}
4523
4548
}
4524
- ["." tmp=RelObjectNameExt() { retval = new RowGetExpression(retval, tmp); }]
4549
+
4550
+
4551
+ // RowGet Expression
4552
+ [ LOOKAHEAD(2) "." tmp=RelObjectNameExt() { retval = new RowGetExpression(retval, tmp); }]
4525
4553
)
4526
4554
)
4527
4555
@@ -4535,7 +4563,7 @@ Expression PrimaryExpression() #PrimaryExpression:
4535
4563
4536
4564
[ LOOKAHEAD(2) retval = ArrayExpression(retval) ]
4537
4565
4538
- ( "::" type=ColDataType() {
4566
+ ( LOOKAHEAD(2) "::" type=ColDataType() {
4539
4567
castExpr = new CastExpression();
4540
4568
castExpr.setUseCastKeyword(false);
4541
4569
castExpr.setLeftExpression(retval);
@@ -4546,8 +4574,8 @@ Expression PrimaryExpression() #PrimaryExpression:
4546
4574
4547
4575
// Check for JSON operands
4548
4576
[
4549
- LOOKAHEAD(2) (
4550
- "->" (token=<S_CHAR_LITERAL> | token=<S_LONG>) { jsonIdents.add(new AbstractMap.SimpleEntry<String, String>(token.image,"->")); }
4577
+ LOOKAHEAD(2) (
4578
+ "->" ( token=<S_CHAR_LITERAL> | token=<S_LONG>) { jsonIdents.add(new AbstractMap.SimpleEntry<String, String>(token.image,"->")); }
4551
4579
|
4552
4580
"->>" (token=<S_CHAR_LITERAL> | token=<S_LONG>) { jsonIdents.add(new AbstractMap.SimpleEntry<String, String>(token.image,"->>")); }
4553
4581
|
@@ -4784,17 +4812,6 @@ StructType StructType() #StruckType:
4784
4812
}
4785
4813
}
4786
4814
4787
- Expression ParenthesedExpression():
4788
- {
4789
- Expression expression;
4790
- }
4791
- {
4792
- "(" expression = PrimaryExpression() ")"
4793
- {
4794
- return new ParenthesedExpressionList(expression);
4795
- }
4796
- }
4797
-
4798
4815
JsonExpression JsonExpression(Expression expr, List<Map.Entry<String, String>> idents) : {
4799
4816
JsonExpression result = new JsonExpression(expr, idents);
4800
4817
Token token;
@@ -5453,28 +5470,22 @@ FullTextSearch FullTextSearch() : {
5453
5470
5454
5471
LambdaExpression LambdaExpression() #LambdaExpression:
5455
5472
{
5473
+ ExpressionList<Column> columns;
5456
5474
String s;
5457
- ArrayList<String> identifiers = new ArrayList<String>();
5458
5475
Expression expression;
5459
5476
LambdaExpression lambdaExpression;
5460
5477
}
5461
5478
{
5462
- // wip, right now the Grammar works but collides with Multi Value Lists
5463
- // (
5464
- // LOOKAHEAD(3) "("
5465
- // s = RelObjectName() { identifiers.add(s); }
5466
- // ( "," s = RelObjectName() { identifiers.add(s); } )*
5467
- // ")"
5468
- // )
5469
- // |
5470
5479
(
5471
- s = RelObjectName() { identifiers.add(s); }
5480
+ columns = ParenthesedColumnList()
5481
+ |
5482
+ s = RelObjectName() { columns = new ExpressionList<Column>(new Column(s)); }
5472
5483
)
5473
5484
5474
5485
"->"
5475
5486
expression = Expression()
5476
5487
{
5477
- lambdaExpression = new LambdaExpression(identifiers , expression);
5488
+ lambdaExpression = LambdaExpression.from(columns , expression);
5478
5489
linkAST(lambdaExpression,jjtThis);
5479
5490
return lambdaExpression;
5480
5491
}
@@ -5559,7 +5570,7 @@ Function SimpleFunction():
5559
5570
}
5560
5571
}
5561
5572
5562
- [ "." (
5573
+ [ LOOKAHEAD(2) "." (
5563
5574
// tricky lookahead since we do need to support the following constructs
5564
5575
// schema.f1().f2() - Function with Function Column
5565
5576
// schema.f1().f2.f3 - Function with Attribute Column
@@ -5632,7 +5643,7 @@ Function InternalFunction(boolean escaped):
5632
5643
")"
5633
5644
5634
5645
5635
- [ "." (
5646
+ [ LOOKAHEAD(2) "." (
5636
5647
// tricky lookahead since we do need to support the following constructs
5637
5648
// schema.f1().f2() - Function with Function Column
5638
5649
// schema.f1().f2.f3 - Function with Attribute Column
@@ -5862,7 +5873,8 @@ CreateSchema CreateSchema():
5862
5873
table.getTable().setSchemaName(schema.getSchemaName());
5863
5874
schema.addStatement(table);
5864
5875
}
5865
- | view = CreateView(false)
5876
+ |
5877
+ view = CreateView(false)
5866
5878
{
5867
5879
view.getView().setSchemaName(schema.getSchemaName());
5868
5880
schema.addStatement(view);
@@ -6209,7 +6221,7 @@ ColDataType ColDataType():
6209
6221
| tk=<K_DATA>
6210
6222
) { schema = tk.image; }
6211
6223
6212
- [ "." arrayType = ColDataType() { schema += "." + arrayType.toString(); } ]
6224
+ [ LOOKAHEAD(2) "." arrayType = ColDataType() { schema += "." + arrayType.toString(); } ]
6213
6225
{ colDataType.setDataType(schema); }
6214
6226
)
6215
6227
@@ -7753,7 +7765,7 @@ String IdentifierChain():
7753
7765
}
7754
7766
{
7755
7767
identifierChain=RelObjectNameExt2()
7756
- ( "." part=RelObjectNameExt2() { identifierChain += "." + part; } )*
7768
+ ( LOOKAHEAD(2) "." part=RelObjectNameExt2() { identifierChain += "." + part; } )*
7757
7769
7758
7770
{
7759
7771
return identifierChain;
0 commit comments