[Feature](Nereids): add logical operator || && (#15643)

This commit is contained in:
谢健
2023-01-06 12:18:21 +08:00
committed by GitHub
parent df2da89b89
commit ef72b8d859
4 changed files with 36 additions and 2 deletions

View File

@ -413,6 +413,7 @@ SLASH: '/';
PERCENT: '%';
TILDE: '~';
AMPERSAND: '&';
LOGICALAND: '&&';
PIPE: '|';
CONCAT_PIPE: '||';
HAT: '^';

View File

@ -243,8 +243,8 @@ booleanExpression
| (ISNULL | IS_NULL_PRED) LEFT_PAREN valueExpression RIGHT_PAREN #isnull
| IS_NOT_NULL_PRED LEFT_PAREN valueExpression RIGHT_PAREN #is_not_null_pred
| valueExpression predicate? #predicated
| left=booleanExpression operator=AND right=booleanExpression #logicalBinary
| left=booleanExpression operator=OR right=booleanExpression #logicalBinary
| left=booleanExpression operator=(AND | LOGICALAND) right=booleanExpression #logicalBinary
| left=booleanExpression operator=(OR | CONCAT_PIPE) right=booleanExpression #logicalBinary
;
predicate

View File

@ -575,9 +575,11 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
Expression right = getExpression(ctx.right);
switch (ctx.operator.getType()) {
case DorisParser.LOGICALAND:
case DorisParser.AND:
return new And(left, right);
case DorisParser.OR:
case DorisParser.CONCAT_PIPE:
return new Or(left, right);
default:
throw new ParseException("Unsupported logical binary type: " + ctx.operator.getText(), ctx);