mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
[For #18707] MySQL compatibility: support DIV and MOD operators
This commit is contained in:
parent
0b56bec69c
commit
99335563d1
@ -18,6 +18,8 @@ const char * ParserMultiplicativeExpression::operators[] =
|
||||
"*", "multiply",
|
||||
"/", "divide",
|
||||
"%", "modulo",
|
||||
"MOD", "modulo",
|
||||
"DIV", "intDiv",
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@ -81,3 +81,43 @@
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
-4
|
||||
-5
|
||||
-6
|
||||
-7
|
||||
-8
|
||||
-9
|
||||
-10
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
-4
|
||||
-5
|
||||
-6
|
||||
-7
|
||||
-8
|
||||
-9
|
||||
-10
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
-1
|
||||
|
@ -23,3 +23,9 @@ SELECT intDiv(toInt64(number), -1) FROM numbers(1, 10);
|
||||
SELECT intDivOrZero(toInt64(number), -1) FROM numbers(1, 10);
|
||||
SELECT intDiv(number, -number) FROM numbers(1, 10);
|
||||
SELECT intDivOrZero(number, -number) FROM numbers(1, 10);
|
||||
|
||||
SELECT -1 DIV number FROM numbers(1, 10);
|
||||
SELECT toInt32(number) DIV -1 FROM numbers(1, 10);
|
||||
SELECT toInt64(number) DIV -1 FROM numbers(1, 10);
|
||||
SELECT number DIV -number FROM numbers(1, 10);
|
||||
SELECT -1 DIV 0; -- { serverError 153 }
|
||||
|
@ -1,3 +1,7 @@
|
||||
1 -1 1 -1
|
||||
0.125 -0.125 0.125 -0.125
|
||||
1 -1 1 -1
|
||||
1 -1 1 -1
|
||||
0.125 -0.125 0.125 -0.125
|
||||
nan
|
||||
nan
|
||||
|
@ -1,3 +1,7 @@
|
||||
WITH 8.5 AS a, 2.5 AS b SELECT a % b, -a % b, a % -b, -a % -b;
|
||||
WITH 10.125 AS a, 2.5 AS b SELECT a % b, -a % b, a % -b, -a % -b;
|
||||
WITH 8.5 AS a, 2.5 AS b SELECT mod(a, b), MOD(-a, b), modulo(a, -b), moduloOrZero(-a, -b);
|
||||
WITH 8.5 AS a, 2.5 AS b SELECT a MOD b, -a MOD b, a MOD -b, -a MOD -b;
|
||||
WITH 10.125 AS a, 2.5 AS b SELECT a MOD b, -a MOD b, a MOD -b, -a MOD -b;
|
||||
SELECT 3.5 % 0;
|
||||
SELECT 3.5 MOD 0;
|
||||
|
Loading…
Reference in New Issue
Block a user