fix functions with sparse arguments

This commit is contained in:
Anton Popov 2021-12-24 19:39:50 +03:00
parent 75b0aef03a
commit c37f1c40be
3 changed files with 16 additions and 2 deletions

View File

@ -321,7 +321,7 @@ ColumnPtr IExecutableFunction::execute(const ColumnsWithTypeAndName & arguments,
return res->cloneResized(input_rows_count);
/// If default of sparse column is changed after execution of function, convert to full column.
if (!res->isDefaultAt(0))
if (!result_type->supportsSparseSerialization() || !res->isDefaultAt(0))
{
const auto & offsets_data = assert_cast<const ColumnVector<UInt64> &>(*sparse_offsets).getData();
return res->createWithOffsets(offsets_data, (*res)[0], input_rows_count, /*shift=*/ 1);

View File

@ -7,3 +7,9 @@
200 84
800 167
800 167
\N
\N
\N
[]
[]
[]

View File

@ -32,4 +32,12 @@ SELECT count(v), sum(v) FROM t_sparse_pk WHERE k = 0;
SELECT count(v), sum(v) FROM t_full_pk WHERE k = 0;
SELECT count(v), sum(v) FROM t_sparse_pk WHERE k = 0 OR k = 3 OR k = 7 OR k = 8;
SELECT count(v), sum(v) FROM t_full_pk WHERE k = 0 OR k = 3 OR k = 7 OR k = 8;
SELECT count(v), sum(v) FROM t_full_pk WHERE k = 0 OR k = 3 OR k = 7 OR k = 8;
SET force_primary_key = 0;
SELECT (k = NULL) OR (k = 1000) FROM t_sparse_pk LIMIT 3;
SELECT range(k) FROM t_sparse_pk LIMIT 3;
DROP TABLE IF EXISTS t_sparse_pk;
DROP TABLE IF EXISTS t_full_pk;