This commit is contained in:
skyoct 2024-04-08 06:44:11 +00:00
parent 307f69380e
commit 8faa148754
4 changed files with 11 additions and 4 deletions

View File

@ -242,7 +242,7 @@ Constrain the return value between A and B.
**Syntax**
``` sql
if(x, min, max)
clamp(x, min, max)
```
**Arguments**
@ -258,7 +258,7 @@ If the value is less than the minimum value, return the minimum value; if it is
Examples:
```sql
SELECT least(1, 2, 3) result, toTypeName(result) type;
SELECT clamp(1, 2, 3) result, toTypeName(result) type;
```
```response
┌─result─┬─type────┐

View File

@ -37,7 +37,6 @@ public:
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override
{
size_t arg_size = arguments.size();
Columns converted_columns(arg_size);
for (size_t arg = 0; arg < arg_size; ++arg)

View File

@ -2,3 +2,7 @@
20
15
b
0
['hello']
-1
234

View File

@ -1,4 +1,8 @@
SELECT clamp(1, 10, 20);
SELECT clamp(30, 10, 20);
SELECT clamp(15, 10, 20);
SELECT clamp('a', 'b', 'c');
SELECT clamp('a', 'b', 'c');
SELECT clamp(today(), yesterday() - 10, yesterday() + 10) - today()
SELECT clamp([], ['hello'], ['world']);
SELECT clamp(-1., -1000., 18446744073709551615.);
SELECT clamp(toNullable(123), 234, 456);