Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ SUBTRACT: '-';
ASTERISK: '*';
SLASH: '/';
MOD: '%';
MOD_ALT: 'MOD';
TILDE: '~';
AMPERSAND: '&';
LOGICALAND: '&&';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ valueExpression
| operator=(SUBTRACT | PLUS | TILDE) valueExpression #arithmeticUnary
// split arithmeticBinary from 1 to 5 due to they have different operator precedence
| left=valueExpression operator=HAT right=valueExpression #arithmeticBinary
| left=valueExpression operator=(ASTERISK | SLASH | MOD | DIV) right=valueExpression #arithmeticBinary
| left=valueExpression operator=(ASTERISK | SLASH | MOD | MOD_ALT | DIV) right=valueExpression #arithmeticBinary
| left=valueExpression operator=(PLUS | SUBTRACT) right=valueExpression #arithmeticBinary
| left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary
| left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary
Expand Down Expand Up @@ -2117,6 +2117,7 @@ nonReserved
| MIN
| MINUTE
| MINUTES
| MOD_ALT
| MODIFY
| MONTH
| MTMV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2999,6 +2999,8 @@ public Expression visitArithmeticBinary(ArithmeticBinaryContext ctx) {
return new Divide(left, right);
case DorisParser.MOD:
return new Mod(left, right);
case DorisParser.MOD_ALT:
return new Mod(left, right);
case DorisParser.PLUS:
return new Add(left, right);
case DorisParser.SUBTRACT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,13 @@
\N \N \N
\N \N \N

-- !arith_op30 --
0.123 0.1 0.3330001831054688
1.500 0.2680000000000007 0.25
0.325 1 0

-- !arith_op31 --
0.123 0.1 0.3330001831054688
1.500 0.2680000000000007 0.25
0.325 1 0

Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ suite("test_arithmetic_operators", "query,p0") {
qt_arith_op27 "select -10.2 / 0.0, -10.2 / 0, -10.2 % 0.0, -10.2 % 0"
qt_arith_op28 "select k5 / 0, k8 / 0, k9 / 0 from ${tableName} order by k1,k2,k3,k4"
qt_arith_op29 "select k5 % 0, k8 % 0, k9 % 0 from ${tableName} order by k1,k2,k3,k4"

qt_arith_op30 "select k5 MOD 3, k8 mod 2, k9 Mod 1 from ${tableName} order by k1,k2,k3,k4"
qt_arith_op31 "select k5 MOD 3, MOD(k8, 2), (k9 MOD 1) as MOD from ${tableName} order by k1,k2,k3,k4"
}
Loading