mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #52659 from CurtizJ/fix-crash-sparse-tuple
Fix crash in function `tuple` with one sparse column argument
This commit is contained in:
commit
2ee83c9c45
@ -37,6 +37,7 @@ public:
|
||||
|
||||
bool canBeInsideNullable() const override { return false; }
|
||||
bool supportsSparseSerialization() const override { return true; }
|
||||
bool canBeInsideSparseColumns() const override { return false; }
|
||||
|
||||
MutableColumnPtr createColumn() const override;
|
||||
MutableColumnPtr createColumn(const ISerialization & serialization) const override;
|
||||
|
@ -110,6 +110,7 @@ public:
|
||||
|
||||
/// TODO: support more types.
|
||||
virtual bool supportsSparseSerialization() const { return !haveSubtypes(); }
|
||||
virtual bool canBeInsideSparseColumns() const { return supportsSparseSerialization(); }
|
||||
|
||||
SerializationPtr getDefaultSerialization() const;
|
||||
SerializationPtr getSparseSerialization() const;
|
||||
|
@ -361,7 +361,7 @@ ColumnPtr IExecutableFunction::execute(const ColumnsWithTypeAndName & arguments,
|
||||
/// If default of sparse column is changed after execution of function, convert to full column.
|
||||
/// If there are any default in non-zero position after execution of function, convert to full column.
|
||||
/// Currently there is no easy way to rebuild sparse column with new offsets.
|
||||
if (!result_type->supportsSparseSerialization() || !res->isDefaultAt(0) || res->getNumberOfDefaultRows() != 1)
|
||||
if (!result_type->canBeInsideSparseColumns() || !res->isDefaultAt(0) || res->getNumberOfDefaultRows() != 1)
|
||||
{
|
||||
const auto & offsets_data = assert_cast<const ColumnVector<UInt64> &>(*sparse_offsets).getData();
|
||||
return res->createWithOffsets(offsets_data, (*res)[0], input_rows_count, /*shift=*/ 1);
|
||||
|
@ -0,0 +1,4 @@
|
||||
(0,0)
|
||||
(0,0)
|
||||
(0,1)
|
||||
(0,NULL)
|
@ -0,0 +1,14 @@
|
||||
drop table if exists t_tuple_sparse;
|
||||
|
||||
create table t_tuple_sparse (a UInt64, b UInt64)
|
||||
ENGINE = MergeTree ORDER BY tuple()
|
||||
SETTINGS ratio_of_defaults_for_sparse_serialization = 0.0;
|
||||
|
||||
insert into t_tuple_sparse values (0, 0);
|
||||
|
||||
select (a, b) from t_tuple_sparse;
|
||||
select (a, 0) from t_tuple_sparse;
|
||||
select (a, 1) from t_tuple_sparse;
|
||||
select (a, NULL) from t_tuple_sparse;
|
||||
|
||||
drop table if exists t_tuple_sparse;
|
Loading…
Reference in New Issue
Block a user