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 <Columns/ColumnNullable.h>
|
||||||
#include <Common/typeid_cast.h>
|
#include <Common/typeid_cast.h>
|
||||||
#include <DataTypes/DataTypeNullable.h>
|
#include <DataTypes/DataTypeNullable.h>
|
||||||
|
#include <IO/ReadHelpers.h>
|
||||||
|
#include <IO/WriteHelpers.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
@ -102,6 +104,8 @@ public:
|
|||||||
Arena * arena) const override
|
Arena * arena) const override
|
||||||
{
|
{
|
||||||
nested_function->merge(place, rhs, arena);
|
nested_function->merge(place, rhs, arena);
|
||||||
|
|
||||||
|
place[size_of_data] |= rhs[size_of_data];
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialize(
|
void serialize(
|
||||||
@ -109,6 +113,8 @@ public:
|
|||||||
WriteBuffer & buf) const override
|
WriteBuffer & buf) const override
|
||||||
{
|
{
|
||||||
nested_function->serialize(place, buf);
|
nested_function->serialize(place, buf);
|
||||||
|
|
||||||
|
writeChar(place[size_of_data], buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserialize(
|
void deserialize(
|
||||||
@ -117,6 +123,8 @@ public:
|
|||||||
Arena * arena) const override
|
Arena * arena) const override
|
||||||
{
|
{
|
||||||
nested_function->deserialize(place, buf, arena);
|
nested_function->deserialize(place, buf, arena);
|
||||||
|
|
||||||
|
readChar(place[size_of_data], buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataTypePtr getReturnType() const override
|
DataTypePtr getReturnType() const override
|
||||||
|
@ -11,6 +11,12 @@
|
|||||||
\N
|
\N
|
||||||
0
|
0
|
||||||
\N
|
\N
|
||||||
|
0
|
||||||
|
\N
|
||||||
|
0
|
||||||
|
\N
|
||||||
|
0
|
||||||
|
\N
|
||||||
--- Int Non-empty ---
|
--- Int Non-empty ---
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
@ -24,6 +30,12 @@ nan
|
|||||||
nan
|
nan
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
nan
|
||||||
|
nan
|
||||||
|
1
|
||||||
|
1
|
||||||
--- Other Types Empty ---
|
--- Other Types Empty ---
|
||||||
|
|
||||||
\N
|
\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 maxOrDefaultIf(x, x > 1) FROM (SELECT 1 AS x);
|
||||||
SELECT maxOrNullIf(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 '--- Int Non-empty ---';
|
||||||
|
|
||||||
SELECT arrayReduce('avgOrDefault', [1]);
|
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 maxOrDefaultIf(x, x > 0) FROM (SELECT 1 AS x);
|
||||||
SELECT maxOrNullIf(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 '--- Other Types Empty ---';
|
||||||
|
|
||||||
SELECT arrayReduce('maxOrDefault', arrayPopBack(['hello']));
|
SELECT arrayReduce('maxOrDefault', arrayPopBack(['hello']));
|
||||||
|
Loading…
Reference in New Issue
Block a user