mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
commit
8f6cd157b9
@ -92,6 +92,50 @@ Result:
|
||||
└───┘
|
||||
```
|
||||
|
||||
## isZeroOrNull
|
||||
|
||||
Returns whether the argument is 0 (zero) or [NULL](../../sql-reference/syntax.md#null-literal).
|
||||
|
||||
``` sql
|
||||
isZeroOrNull(x)
|
||||
```
|
||||
|
||||
**Arguments:**
|
||||
|
||||
- `x` — A value of non-compound data type.
|
||||
|
||||
**Returned value**
|
||||
|
||||
- `1` if `x` is 0 (zero) or `NULL`.
|
||||
- `0` else.
|
||||
|
||||
**Example**
|
||||
|
||||
Table:
|
||||
|
||||
``` text
|
||||
┌─x─┬────y─┐
|
||||
│ 1 │ ᴺᵁᴸᴸ │
|
||||
│ 2 │ 0 │
|
||||
│ 3 │ 3 │
|
||||
└───┴──────┘
|
||||
```
|
||||
|
||||
Query:
|
||||
|
||||
``` sql
|
||||
SELECT x FROM t_null WHERE isZeroOrNull(y);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` text
|
||||
┌─x─┐
|
||||
│ 1 │
|
||||
│ 2 │
|
||||
└───┘
|
||||
```
|
||||
|
||||
## coalesce
|
||||
|
||||
Returns the leftmost non-`NULL` argument.
|
||||
|
@ -44,14 +44,18 @@ public:
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & types) const override
|
||||
{
|
||||
if (!isNumber(removeNullable(types.at(0))))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "The argument of function {} must have simple numeric type, possibly Nullable", name);
|
||||
if (!isNumber(removeNullable(types.at(0))) && !isNothing(removeNullable(types.at(0))))
|
||||
throw Exception(
|
||||
ErrorCodes::BAD_ARGUMENTS, "The argument of function {} must have simple numeric type, possibly Nullable or Null", name);
|
||||
|
||||
return std::make_shared<DataTypeUInt8>();
|
||||
}
|
||||
|
||||
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
|
||||
{
|
||||
if (isNothing(removeNullable(arguments[0].type)))
|
||||
return DataTypeUInt8{}.createColumnConst(input_rows_count, 1);
|
||||
|
||||
const ColumnPtr & input_column = arguments[0].column;
|
||||
|
||||
ColumnPtr res;
|
||||
@ -72,7 +76,10 @@ public:
|
||||
return true;
|
||||
}))
|
||||
{
|
||||
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "The argument of function {} must have simple numeric type, possibly Nullable", name);
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_COLUMN,
|
||||
"The argument of function {} must have simple numeric type, possibly Nullable or Null",
|
||||
name);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -89,7 +96,10 @@ public:
|
||||
return true;
|
||||
}))
|
||||
{
|
||||
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "The argument of function {} must have simple numeric type, possibly Nullable", name);
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_COLUMN,
|
||||
"The argument of function {} must have simple numeric type, possibly Nullable or Null",
|
||||
name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,3 +20,5 @@ world
|
||||
3
|
||||
---
|
||||
4
|
||||
---
|
||||
1
|
||||
|
@ -27,3 +27,7 @@ SELECT count() FROM
|
||||
UNION ALL
|
||||
SELECT * FROM test WHERE isZeroOrNull(x != 'xyz')
|
||||
);
|
||||
|
||||
SELECT '---';
|
||||
|
||||
select isZeroOrNull(Null);
|
||||
|
@ -1329,10 +1329,10 @@ ddl
|
||||
deallocation
|
||||
deallocations
|
||||
debian
|
||||
decodeHTMLComponent
|
||||
decodeURLComponent
|
||||
decodeURLFormComponent
|
||||
decodeXMLComponent
|
||||
decodeHTMLComponent
|
||||
decompressor
|
||||
decrypt
|
||||
decrypted
|
||||
@ -1558,6 +1558,7 @@ gzipped
|
||||
hadoop
|
||||
halfMD
|
||||
halfday
|
||||
hardlink
|
||||
hardlinks
|
||||
hasAll
|
||||
hasAny
|
||||
@ -1637,6 +1638,7 @@ isNotNull
|
||||
isNull
|
||||
isValidJSON
|
||||
isValidUTF
|
||||
isZeroOrNull
|
||||
iteratively
|
||||
jaccard
|
||||
javaHash
|
||||
@ -2582,4 +2584,3 @@ znode
|
||||
znodes
|
||||
zookeeperSessionUptime
|
||||
zstd
|
||||
hardlink
|
||||
|
Loading…
Reference in New Issue
Block a user