mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Fix OrNull and OrDefault
This commit is contained in:
parent
541cd638ba
commit
8a60e22223
@ -4,6 +4,8 @@
|
||||
#include <Columns/ColumnNullable.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -102,6 +104,8 @@ public:
|
||||
Arena * arena) const override
|
||||
{
|
||||
nested_function->merge(place, rhs, arena);
|
||||
|
||||
place[size_of_data] |= rhs[size_of_data];
|
||||
}
|
||||
|
||||
void serialize(
|
||||
@ -109,6 +113,8 @@ public:
|
||||
WriteBuffer & buf) const override
|
||||
{
|
||||
nested_function->serialize(place, buf);
|
||||
|
||||
writeChar(place[size_of_data], buf);
|
||||
}
|
||||
|
||||
void deserialize(
|
||||
@ -117,6 +123,8 @@ public:
|
||||
Arena * arena) const override
|
||||
{
|
||||
nested_function->deserialize(place, buf, arena);
|
||||
|
||||
readChar(place[size_of_data], buf);
|
||||
}
|
||||
|
||||
DataTypePtr getReturnType() const override
|
||||
|
@ -11,6 +11,12 @@
|
||||
\N
|
||||
0
|
||||
\N
|
||||
0
|
||||
\N
|
||||
0
|
||||
\N
|
||||
0
|
||||
\N
|
||||
--- Int Non-empty ---
|
||||
1
|
||||
1
|
||||
@ -24,6 +30,12 @@ nan
|
||||
nan
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
nan
|
||||
nan
|
||||
1
|
||||
1
|
||||
--- Other Types Empty ---
|
||||
|
||||
\N
|
||||
|
@ -14,6 +14,13 @@ SELECT stddevSampOrNullIf(x, x > 1) FROM (SELECT 1 AS x);
|
||||
SELECT maxOrDefaultIf(x, x > 1) FROM (SELECT 1 AS x);
|
||||
SELECT maxOrNullIf(x, x > 1) FROM (SELECT 1 AS x);
|
||||
|
||||
SELECT avgOrDefaultIfMerge(state) FROM (SELECT avgOrDefaultIfState(x, x > 1) AS state FROM (SELECT 1 AS x));
|
||||
SELECT avgOrNullIfMerge(state) FROM (SELECT avgOrNullIfState(x, x > 1) AS state FROM (SELECT 1 AS x));
|
||||
SELECT stddevSampOrDefaultIfMerge(state) FROM (SELECT stddevSampOrDefaultIfState(x, x > 1) AS state FROM (SELECT 1 AS x));
|
||||
SELECT stddevSampOrNullIfMerge(state) FROM (SELECT stddevSampOrNullIfState(x, x > 1) AS state FROM (SELECT 1 AS x));
|
||||
SELECT maxOrDefaultIfMerge(state) FROM (SELECT maxOrDefaultIfState(x, x > 1) AS state FROM (SELECT 1 AS x));
|
||||
SELECT maxOrNullIfMerge(state) FROM (SELECT maxOrNullIfState(x, x > 1) AS state FROM (SELECT 1 AS x));
|
||||
|
||||
SELECT '--- Int Non-empty ---';
|
||||
|
||||
SELECT arrayReduce('avgOrDefault', [1]);
|
||||
@ -30,6 +37,13 @@ SELECT stddevSampOrNullIf(x, x > 0) FROM (SELECT 1 AS x);
|
||||
SELECT maxOrDefaultIf(x, x > 0) FROM (SELECT 1 AS x);
|
||||
SELECT maxOrNullIf(x, x > 0) FROM (SELECT 1 AS x);
|
||||
|
||||
SELECT avgOrDefaultIfMerge(state) FROM (SELECT avgOrDefaultIfState(x, x > 0) AS state FROM (SELECT 1 AS x));
|
||||
SELECT avgOrNullIfMerge(state) FROM (SELECT avgOrNullIfState(x, x > 0) AS state FROM (SELECT 1 AS x));
|
||||
SELECT stddevSampOrDefaultIfMerge(state) FROM (SELECT stddevSampOrDefaultIfState(x, x > 0) AS state FROM (SELECT 1 AS x));
|
||||
SELECT stddevSampOrNullIfMerge(state) FROM (SELECT stddevSampOrNullIfState(x, x > 0) AS state FROM (SELECT 1 AS x));
|
||||
SELECT maxOrDefaultIfMerge(state) FROM (SELECT maxOrDefaultIfState(x, x > 0) AS state FROM (SELECT 1 AS x));
|
||||
SELECT maxOrNullIfMerge(state) FROM (SELECT maxOrNullIfState(x, x > 0) AS state FROM (SELECT 1 AS x));
|
||||
|
||||
SELECT '--- Other Types Empty ---';
|
||||
|
||||
SELECT arrayReduce('maxOrDefault', arrayPopBack(['hello']));
|
||||
|
Loading…
Reference in New Issue
Block a user