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 @@ -37,6 +37,6 @@ SELECT COSINE_DISTANCE([1, 2], [2, 3]),COSINE_DISTANCE([3, 6], [4, 7]);
+---------------------------------+---------------------------------+
| cosine_distance([1, 2], [2, 3]) | cosine_distance([3, 6], [4, 7]) |
+---------------------------------+---------------------------------+
| 0.007722123286332261 | 0.0015396467945875125 |
| 0.007722139 | 0.001539648 |
+---------------------------------+---------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ SELECT L2_DISTANCE([4, 5], [6, 8]),L2_DISTANCE([3, 6], [4, 5]);
+-----------------------------+-----------------------------+
| l2_distance([4, 5], [6, 8]) | l2_distance([3, 6], [4, 5]) |
+-----------------------------+-----------------------------+
| 3.605551275463989 | 1.4142135623730951 |
| 3.605551 | 1.414214 |
+-----------------------------+-----------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ SELECT array_concat(int_array1, int_array2) FROM array_concat_test WHERE id = 5;
+--------------------------------------+
```

Type compatibility example: concatenating int_array1 and string_array1, string elements cannot be converted to int, resulting in null.
Type compatibility example: concatenating int_array1 and string_array1 converts integer elements to strings and retains all elements.
```sql
SELECT array_concat(int_array1, string_array1) FROM array_concat_test WHERE id = 1;
+-----------------------------------------+
| array_concat(int_array1, string_array1) |
+-----------------------------------------+
| [1, 2, 3, null, null] |
| ["1", "2", "3", "a", "b"] |
+-----------------------------------------+
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ SELECT array_cum_sum(['a', 1, 'b', 2, 'c', 3]);
+-----------------------------------------+
| array_cum_sum(['a', 1, 'b', 2, 'c', 3]) |
+-----------------------------------------+
| [0, 1, 1, 3, 3, 6] |
| [null, 1, null, 3, null, 6] |
+-----------------------------------------+
```

Hello Hello.,Hello123hello
Hello Hello.,Hello123hello
Empty array returns empty array:
```sql
SELECT array_cum_sum(int_array) FROM array_cum_sum_test WHERE id = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ SELECT array_popback([[1, 2], [3, 4], [5, 6]]);
Remove the last element from a MAP array:
```sql
SELECT array_popback([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]);
+------------------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------+
| array_popback([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]) |
+------------------------------------------------------------------------------------------+
| [{"name":"Alice","age":20}, {"name":"Bob","age":30}] |
+------------------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------+
| [{"name":"Alice", "age":"20"}, {"name":"Bob", "age":"30"}] |
+--------------------------------------------------------------------------------------------------+
```

Remove the last element from a STRUCT array:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ SELECT array_popfront([[1, 2], [3, 4], [5, 6]]);
Remove the first element from a MAP array:
```sql
SELECT array_popfront([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]);
+------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------+
| array_popfront([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]) |
+------------------------------------------------------------------------------------------+
| [{"name":"Bob","age":30}, {"name":"Charlie","age":40}] |
+------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------+
| [{"name":"Bob", "age":"30"}, {"name":"Charlie", "age":"40"}] |
+---------------------------------------------------------------------------------------------------+
```

Remove the first element from a STRUCT array:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The result will be:
+--------------------------------+
| bitmap_to_base64(to_bitmap(1)) |
+--------------------------------+
| AQEAAAA= |
| BQEBAAAAAAAAAA== |
+--------------------------------+
```

Expand All @@ -96,6 +96,6 @@ The result will be:
+---------------------------------------------------------+
| bitmap_to_base64(bitmap_from_string("1,9999999")) |
+---------------------------------------------------------+
| AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y= |
| BQIBAAAAAAAAAH+WmAAAAAAA |
+---------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ select extract(year_month from '2026-01-01 11:45:14.123456') as year_month,
extract(minute_microsecond from '2026-01-01 11:45:14.123456') as minute_microsecond,
extract(second_microsecond from '2026-01-01 11:45:14.123456') as second_microsecond;

+------------+----------+------------+-------------+-----------------------+-------------+-------------+-----------------------+--------------+----------------------+-------------------+
| year_month | day_hour | day_minute | day_second | day_microsecond | hour_minute | hour_second | hour_microsecond | minute_second| minute_microsecond | second_microsecond |
+------------+----------+------------+-------------+-----------------------+-------------+-------------+-----------------------+--------------+----------------------+-------------------+
| 2026-01 | 1 11 | 1 11:45 | 1 11:45:14 | 1 11:45:14.123456 | 11:45 | 11:45:14 | 11:45:14.123456 | 45:14 | 45:14.123456 | 14.123456 |
+------------+----------+------------+-------------+-----------------------+-------------+-------------+-----------------------+--------------+----------------------+-------------------+
+------------+----------+------------+-------------+--------------------+-------------+-------------+------------------+---------------+--------------------+--------------------+
| year_month | day_hour | day_minute | day_second | day_microsecond | hour_minute | hour_second | hour_microsecond | minute_second | minute_microsecond | second_microsecond |
+------------+----------+------------+-------------+--------------------+-------------+-------------+------------------+---------------+--------------------+--------------------+
| 2026-01 | 01 11 | 01 11:45 | 01 11:45:14 | 01 11:45:14.123456 | 11:45 | 11:45:14 | 11:45:14.123456 | 45:14 | 45:14.123456 | 14.123456 |
+------------+----------+------------+-------------+--------------------+-------------+-------------+------------------+---------------+--------------------+--------------------+

-- Input unit does not exist, reports error
select extract(uint from '2024-01-07') as week;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ SELECT MONTH_FLOOR('2023-07-13 22:28:18', 5, '2023-01-01 00:00:00') AS result;

-- Datetime with scale, time component and decimal places are all truncated to 0
SELECT MONTH_FLOOR('2023-07-13 22:28:18.456789', 5) AS result;
+---------------------+
| result |
+---------------------+
| 2023-06-01 00:00:00 |
+---------------------+
+----------------------------+
| result |
+----------------------------+
| 2023-05-01 00:00:00.000000 |
+----------------------------+

-- Input is of DATE type (default time 00:00:00)
SELECT MONTH_FLOOR('2023-07-13', 3) AS result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ SELECT TIMEDIFF('2024-01-01 00:00:01', '2023-12-31 23:59:59') AS result;

-- When returned time is not an integer number of seconds, returns time with scale
SELECT TIMEDIFF('2023-07-13 12:34:56.789', '2023-07-13 12:34:50.123') AS result;
+-----------+
| result |
+-----------+
| 00:00:06 |
+-----------+
+--------------+
| result |
+--------------+
| 00:00:06.666 |
+--------------+

-- Calculation result exceeds time size range, returns error
SELECT TIMEDIFF('2023-07-13 12:34:56.789', '2024-07-13 12:34:50.123') AS result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ JSON_EXTRACT (<json_object>, <path>[, <path2>, ...])
```
> Even if there is only one match, it will be returned in array form
```sql
select JSON_EXTRACT('{"id": 123, "name": "doris"}', '$.name', '$.id2', '$.not_exists');
SELECT json_extract('{"id": 123, "name": "doris"}', '$.aaa', '$.name');
```
```
+---------------------------------------------------------------------------------+
| JSON_EXTRACT('{"id": 123, "name": "doris"}', '$.name', '$.id2', '$.not_exists') |
+---------------------------------------------------------------------------------+
| ["doris"] |
+---------------------------------------------------------------------------------+
+-----------------------------------------------------------------+
| json_extract('{"id": 123, "name": "doris"}', '$.aaa', '$.name') |
+-----------------------------------------------------------------+
| ["doris"] |
+-----------------------------------------------------------------+
```
> If all paths have no matches, return NULL
```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ select fmod(10.1, 3.2);
```

```text
+-----------------+
| fmod(10.1, 3.2) |
+-----------------+
| 0.50000024 |
+-----------------+
+--------------------+
| fmod(10.1, 3.2) |
+--------------------+
| 0.4999999999999991 |
+--------------------+
```

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ SELECT auto_partition_name('list', 'hello', 'world');
SELECT auto_partition_name('list', 'ṭṛì', 'ḍḍumai');
```
```text
+------------------------------------------------+
| auto_partition_name('list', 'ṭṛì', 'ḍḍumai') |
+------------------------------------------------+
| pṭṛì9ḍḍumai12 |
+------------------------------------------------+
+-------------------------------------------------------+
| auto_partition_name('list', 'ṭṛì', 'ḍḍumai') |
+-------------------------------------------------------+
| p1e6d1e5bec31e0d1e0dumai6 |
+-------------------------------------------------------+
```

6. Invalid unit parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ SELECT TO_BASE64('ṭṛì'), TO_BASE64('ḍḍumai hello');
+-------------------+---------------------------+
| TO_BASE64('ṭṛì') | TO_BASE64('ḍḍumai hello') |
+-------------------+---------------------------+
| 4bmt4bmb4bmA | 4bmN4bmNdW1haSBoZWxsbw== |
| 4bmt4bmbw6w= | 4bmN4bmNdW1haSBoZWxsbw== |
+-------------------+---------------------------+
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ SELECT COSINE_DISTANCE([1, 2], [2, 3]),COSINE_DISTANCE([3, 6], [4, 7]);
+---------------------------------+---------------------------------+
| cosine_distance([1, 2], [2, 3]) | cosine_distance([3, 6], [4, 7]) |
+---------------------------------+---------------------------------+
| 0.007722123286332261 | 0.0015396467945875125 |
| 0.007722139 | 0.001539648 |
+---------------------------------+---------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ SELECT L2_DISTANCE([4, 5], [6, 8]),L2_DISTANCE([3, 6], [4, 5]);
+-----------------------------+-----------------------------+
| l2_distance([4, 5], [6, 8]) | l2_distance([3, 6], [4, 5]) |
+-----------------------------+-----------------------------+
| 3.605551275463989 | 1.4142135623730951 |
| 3.605551 | 1.414214 |
+-----------------------------+-----------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ SELECT array_concat(int_array1, int_array2) FROM array_concat_test WHERE id = 5;
+--------------------------------------+
```

类型兼容性示例:int_array1 和 string_array1 拼接,string 元素无法转换为 int,结果为 null
类型兼容性示例:int_array1 和 string_array1 拼接,int 元素会转换为 string,所有元素都会保留
```sql
SELECT array_concat(int_array1, string_array1) FROM array_concat_test WHERE id = 1;
+-----------------------------------------+
| array_concat(int_array1, string_array1) |
+-----------------------------------------+
| [1, 2, 3, null, null] |
| ["1", "2", "3", "a", "b"] |
+-----------------------------------------+
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ SELECT array_cum_sum(['a', 1, 'b', 2, 'c', 3]);
+-----------------------------------------+
| array_cum_sum(['a', 1, 'b', 2, 'c', 3]) |
+-----------------------------------------+
| [0, 1, 1, 3, 3, 6] |
| [null, 1, null, 3, null, 6] |
+-----------------------------------------+
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ SELECT array_popback([[1, 2], [3, 4], [5, 6]]);
移除 MAP 数组的最后一个元素:
```sql
SELECT array_popback([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]);
+------------------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------+
| array_popback([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]) |
+------------------------------------------------------------------------------------------+
| [{"name":"Alice","age":20}, {"name":"Bob","age":30}] |
+------------------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------+
| [{"name":"Alice", "age":"20"}, {"name":"Bob", "age":"30"}] |
+--------------------------------------------------------------------------------------------------+
```

移除 STRUCT 数组的最后一个元素:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ SELECT array_popfront([[1, 2], [3, 4], [5, 6]]);
移除 MAP 数组的第一个元素:
```sql
SELECT array_popfront([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]);
+------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------+
| array_popfront([{'name':'Alice','age':20}, {'name':'Bob','age':30}, {'name':'Charlie','age':40}]) |
+------------------------------------------------------------------------------------------+
| [{"name":"Bob","age":30}, {"name":"Charlie","age":40}] |
+------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------+
| [{"name":"Bob", "age":"30"}, {"name":"Charlie", "age":"40"}] |
+---------------------------------------------------------------------------------------------------+
```

移除 STRUCT 数组的第一个元素:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ select bitmap_to_base64(to_bitmap(1));
+--------------------------------+
| bitmap_to_base64(to_bitmap(1)) |
+--------------------------------+
| AQEAAAA= |
| BQEBAAAAAAAAAA== |
+--------------------------------+
```

Expand All @@ -96,6 +96,6 @@ select bitmap_to_base64(bitmap_from_string("1,9999999"));
+---------------------------------------------------------+
| bitmap_to_base64(bitmap_from_string("1,9999999")) |
+---------------------------------------------------------+
| AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y= |
| BQIBAAAAAAAAAH+WmAAAAAAA |
+---------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ select extract(year_month from '2026-01-01 11:45:14.123456') as year_month,
extract(minute_microsecond from '2026-01-01 11:45:14.123456') as minute_microsecond,
extract(second_microsecond from '2026-01-01 11:45:14.123456') as second_microsecond;

+------------+----------+------------+-------------+-----------------------+-------------+-------------+-----------------------+--------------+----------------------+-------------------+
| year_month | day_hour | day_minute | day_second | day_microsecond | hour_minute | hour_second | hour_microsecond | minute_second| minute_microsecond | second_microsecond |
+------------+----------+------------+-------------+-----------------------+-------------+-------------+-----------------------+--------------+----------------------+-------------------+
| 2026-01 | 1 11 | 1 11:45 | 1 11:45:14 | 1 11:45:14.123456 | 11:45 | 11:45:14 | 11:45:14.123456 | 45:14 | 45:14.123456 | 14.123456 |
+------------+----------+------------+-------------+-----------------------+-------------+-------------+-----------------------+--------------+----------------------+-------------------+
+------------+----------+------------+-------------+--------------------+-------------+-------------+------------------+---------------+--------------------+--------------------+
| year_month | day_hour | day_minute | day_second | day_microsecond | hour_minute | hour_second | hour_microsecond | minute_second | minute_microsecond | second_microsecond |
+------------+----------+------------+-------------+--------------------+-------------+-------------+------------------+---------------+--------------------+--------------------+
| 2026-01 | 01 11 | 01 11:45 | 01 11:45:14 | 01 11:45:14.123456 | 11:45 | 11:45:14 | 11:45:14.123456 | 45:14 | 45:14.123456 | 14.123456 |
+------------+----------+------------+-------------+--------------------+-------------+-------------+------------------+---------------+--------------------+--------------------+

-- 输入单位不存在,报错
select extract(uint from '2024-01-07') as week;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ SELECT MONTH_FLOOR('2023-07-13 22:28:18', 5, '2023-01-01 00:00:00') AS result;
+---------------------+
| result |
+---------------------+
| 2023-07-13 22:25:00 |
| 2023-06-01 00:00:00 |
+---------------------+

--- 带有 scale 的 datetime,会把小数位全部截断为 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ SELECT TIMEDIFF('2024-01-01 00:00:01', '2023-12-31 23:59:59') AS result;

-- 返回时间不是整数秒时,返回时间带有 scale
SELECT TIMEDIFF('2023-07-13 12:34:56.789', '2023-07-13 12:34:50.123') AS result;
+-----------+
| result |
+-----------+
| 00:00:06 |
+-----------+
+--------------+
| result |
+--------------+
| 00:00:06.666 |
+--------------+

---计算结果超出 time 大小范围,返回错误
SELECT TIMEDIFF('2023-07-13 12:34:56.789', '2024-07-13 12:34:50.123') AS result;
Expand Down
Loading
Loading