Files
greptimedb/tests/cases/standalone/common/function/arithmetic.result
Ruihang Xia d8939eb891 feat: clamp function (#3465)
* basic impl

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* add unit tests

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* a little type exercise

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* add sqlness case

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
2024-03-11 03:26:10 +00:00

81 lines
2.0 KiB
Plaintext

SELECT MOD(18, 4);
+-------------------------+
| mod(Int64(18),Int64(4)) |
+-------------------------+
| 2 |
+-------------------------+
SELECT MOD(-18, 4);
+--------------------------+
| mod(Int64(-18),Int64(4)) |
+--------------------------+
| -2 |
+--------------------------+
SELECT MOD(18.0, 4.0);
+-----------------------------+
| mod(Float64(18),Float64(4)) |
+-----------------------------+
| 2.0 |
+-----------------------------+
SELECT MOD(18, 0);
Error: 3001(EngineExecuteQuery), DataFusion error: Divide by zero error
SELECT POW (2, 5);
+------------------------+
| pow(Int64(2),Int64(5)) |
+------------------------+
| 32.0 |
+------------------------+
SELECT POW (1.01, 365);
+-------------------------------+
| pow(Float64(1.01),Int64(365)) |
+-------------------------------+
| 37.78343433288728 |
+-------------------------------+
SELECT POW (0.99, 365);
+-------------------------------+
| pow(Float64(0.99),Int64(365)) |
+-------------------------------+
| 0.025517964452291125 |
+-------------------------------+
SELECT CLAMP(10, 0, 1);
+------------------------------------+
| clamp(Int64(10),Int64(0),Int64(1)) |
+------------------------------------+
| 1 |
+------------------------------------+
SELECT CLAMP(-10, 0, 1);
+-------------------------------------+
| clamp(Int64(-10),Int64(0),Int64(1)) |
+-------------------------------------+
| 0 |
+-------------------------------------+
SELECT CLAMP(0.5, 0, 1);
+---------------------------------------+
| clamp(Float64(0.5),Int64(0),Int64(1)) |
+---------------------------------------+
| 0.5 |
+---------------------------------------+
SELECT CLAMP(10, 1, 0);
Error: 3001(EngineExecuteQuery), DataFusion error: Invalid function args: The second arg should be less than or equal to the third arg, have: ConstantVector([Int64(1); 1]), ConstantVector([Int64(0); 1])