mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #18760 from spongedu/fix_#18701
[For #18707] MySQL compatibility: support DIV and MOD operators
This commit is contained in:
commit
202d1f2211
@ -18,6 +18,8 @@ const char * ParserMultiplicativeExpression::operators[] =
|
|||||||
"*", "multiply",
|
"*", "multiply",
|
||||||
"/", "divide",
|
"/", "divide",
|
||||||
"%", "modulo",
|
"%", "modulo",
|
||||||
|
"MOD", "modulo",
|
||||||
|
"DIV", "intDiv",
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,3 +81,43 @@
|
|||||||
-1
|
-1
|
||||||
-1
|
-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 intDivOrZero(toInt64(number), -1) FROM numbers(1, 10);
|
||||||
SELECT intDiv(number, -number) FROM numbers(1, 10);
|
SELECT intDiv(number, -number) FROM numbers(1, 10);
|
||||||
SELECT intDivOrZero(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
|
1 -1 1 -1
|
||||||
0.125 -0.125 0.125 -0.125
|
0.125 -0.125 0.125 -0.125
|
||||||
1 -1 1 -1
|
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 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 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 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