mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
change name of tuple vector functions
This commit is contained in:
parent
1d52b1f020
commit
0b6cf8e5ee
@ -596,14 +596,14 @@ Result:
|
|||||||
└──────────────────────────────────┘
|
└──────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## tupleDivideOrNullByNumber
|
## tupleDivideByNumberOrNull
|
||||||
|
|
||||||
Like [tupleDivideByNumber](#tupleDivideByNumber), but division by zero will return `NULL`.
|
Like [tupleDivideByNumber](#tupleDivideByNumber), but division by zero will return `NULL`.
|
||||||
|
|
||||||
**Syntax**
|
**Syntax**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
tupleDivideOrNullByNumber(tuple, number)
|
tupleDivideByNumberOrNull(tuple, number)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Arguments**
|
**Arguments**
|
||||||
@ -620,13 +620,13 @@ tupleDivideOrNullByNumber(tuple, number)
|
|||||||
Query:
|
Query:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT tupleDivideOrNullByNumber((1, 2), 0.0);
|
SELECT tupleDivideByNumberOrNull((1, 2), 0.0);
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
┌─tupleDivideOrNullByNumber((1, 2), 0.)─┐
|
┌─tupleDivideByNumberOrNull((1, 2), 0.)─┐
|
||||||
│ (NULL,NULL) │
|
│ (NULL,NULL) │
|
||||||
└───────────────────────────────────────┘
|
└───────────────────────────────────────┘
|
||||||
```
|
```
|
||||||
@ -970,7 +970,7 @@ Like [tupleModuloByNumber](#tuplemodulobynumber) it returns a tuple of the modul
|
|||||||
**Syntax**
|
**Syntax**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
tupleModuloOrNullByNumber(tuple_num, div)
|
tupleModuloByNumberOrNull(tuple_num, div)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
@ -988,13 +988,13 @@ tupleModuloOrNullByNumber(tuple_num, div)
|
|||||||
Query:
|
Query:
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
SELECT tupleModuloOrNullByNumber((15, 10, 5), 0);
|
SELECT tupleModuloByNumberOrNull((15, 10, 5), 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
``` text
|
``` text
|
||||||
┌─tupleModuloOrNullByNumber((15, 10, 5), 0)─┐
|
┌─tupleModuloByNumberOrNull((15, 10, 5), 0)─┐
|
||||||
│ (NULL,NULL,NULL) │
|
│ (NULL,NULL,NULL) │
|
||||||
└───────────────────────────────────────────┘
|
└───────────────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
@ -218,7 +218,7 @@ checkAndGetNestedArrayOffset(const IColumn ** columns, size_t num_arguments)
|
|||||||
return {nested_columns, offsets->data()};
|
return {nested_columns, offsets->data()};
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnPtr
|
ColumnPtr
|
||||||
wrapInNullable(const ColumnPtr & src, const ColumnsWithTypeAndName & args, const DataTypePtr & result_type, size_t input_rows_count, const NullMap * res_null_map)
|
wrapInNullable(const ColumnPtr & src, const ColumnsWithTypeAndName & args, const DataTypePtr & result_type, size_t input_rows_count, const NullMap * res_null_map)
|
||||||
{
|
{
|
||||||
ColumnPtr result_null_map_column;
|
ColumnPtr result_null_map_column;
|
||||||
|
@ -48,7 +48,7 @@ struct DivideOrNullImpl
|
|||||||
c[i] = ResultType();
|
c[i] = ResultType();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c[i] = -a[i];
|
c[i] = static_cast<ResultType>(-a[i]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ struct DivideOrNullImpl
|
|||||||
*m = 1;
|
*m = 1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
return -a;
|
return static_cast<ResultType>(-a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return static_cast<ResultType>(a) / b;
|
return static_cast<ResultType>(a) / b;
|
||||||
|
@ -73,6 +73,16 @@ constexpr std::string makeFirstLetterUppercase(const std::string & str)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool endWith(const std::string & str, const std::string & needle)
|
||||||
|
{
|
||||||
|
return str.size() >= needle.size() && str.compare(str.size() - needle.size(), needle.size(), needle) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr std::string dropNeedle(const std::string & str, const std::string & needle)
|
||||||
|
{
|
||||||
|
return endWith(str, needle) ? str.substr(0, str.size() - needle.size()) : str;
|
||||||
|
}
|
||||||
|
|
||||||
template <class FuncName>
|
template <class FuncName>
|
||||||
class FunctionTupleOperator : public ITupleFunction
|
class FunctionTupleOperator : public ITupleFunction
|
||||||
{
|
{
|
||||||
@ -240,7 +250,7 @@ class FunctionTupleOperatorByNumber : public ITupleFunction
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// constexpr cannot be used due to std::string has not constexpr constructor in this compiler version
|
/// constexpr cannot be used due to std::string has not constexpr constructor in this compiler version
|
||||||
static inline auto name = "tuple" + makeFirstLetterUppercase(FuncName::name) + "ByNumber";
|
static inline auto name = "tuple" + makeFirstLetterUppercase(dropNeedle(FuncName::name, "OrNull")) + "ByNumber" + (endWith(FuncName::name, "OrNull") ? "OrNull" : "");
|
||||||
|
|
||||||
explicit FunctionTupleOperatorByNumber(ContextPtr context_) : ITupleFunction(context_) {}
|
explicit FunctionTupleOperatorByNumber(ContextPtr context_) : ITupleFunction(context_) {}
|
||||||
static FunctionPtr create(ContextPtr context_) { return std::make_shared<FunctionTupleOperatorByNumber>(context_); }
|
static FunctionPtr create(ContextPtr context_) { return std::make_shared<FunctionTupleOperatorByNumber>(context_); }
|
||||||
|
@ -35,5 +35,5 @@ SELECT moduloOrNull(materialize(16.2), materialize(0.0));
|
|||||||
|
|
||||||
SELECT tupleModuloOrNull((15, 10, 5), (0, 3, 2));
|
SELECT tupleModuloOrNull((15, 10, 5), (0, 3, 2));
|
||||||
SELECT tupleModuloOrNull((15, 10, 5), (5, 3, 2));
|
SELECT tupleModuloOrNull((15, 10, 5), (5, 3, 2));
|
||||||
SELECT tupleModuloOrNullByNumber((15, 10, 5), 0);
|
SELECT tupleModuloByNumberOrNull((15, 10, 5), 0);
|
||||||
SELECT tupleModuloOrNullByNumber((15, 10, 5), 2);
|
SELECT tupleModuloByNumberOrNull((15, 10, 5), 2);
|
||||||
|
@ -34,5 +34,5 @@ SELECT divideOrNull(materialize(toDecimal32(16.2, 2)), materialize(0.0));
|
|||||||
|
|
||||||
SELECT tupleDivideOrNull((15, 10, 5), (0, 0, 0));
|
SELECT tupleDivideOrNull((15, 10, 5), (0, 0, 0));
|
||||||
SELECT tupleDivideOrNull((15, 10, 5), (5, 0, 0));
|
SELECT tupleDivideOrNull((15, 10, 5), (5, 0, 0));
|
||||||
SELECT tupleDivideOrNullByNumber((15, 10, 5), 5);
|
SELECT tupleDivideByNumberOrNull((15, 10, 5), 5);
|
||||||
SELECT tupleDivideOrNullByNumber((15, 10, 5), 0);
|
SELECT tupleDivideByNumberOrNull((15, 10, 5), 0);
|
||||||
|
@ -3160,7 +3160,7 @@ zstd
|
|||||||
divideOrNull
|
divideOrNull
|
||||||
moduloOrNull
|
moduloOrNull
|
||||||
tupleDivideOrNull
|
tupleDivideOrNull
|
||||||
tupleDivideOrNullByNumber
|
tupleDivideByNumberOrNull
|
||||||
tupleModuloByNumberOrNull
|
tupleModuloByNumberOrNull
|
||||||
tupleModuloOrNull
|
tupleModuloOrNull
|
||||||
BFloat
|
BFloat
|
||||||
|
Loading…
Reference in New Issue
Block a user