mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Improved performance of function arrayElement with constant array when one of element is an empty array #1889
This commit is contained in:
parent
ac0d1f8fba
commit
3656aa0606
@ -61,6 +61,13 @@ void FunctionArray::executeImpl(Block & block, const ColumnNumbers & arguments,
|
|||||||
{
|
{
|
||||||
size_t num_elements = arguments.size();
|
size_t num_elements = arguments.size();
|
||||||
|
|
||||||
|
if (num_elements == 0)
|
||||||
|
{
|
||||||
|
/// We should return constant empty array.
|
||||||
|
block.getByPosition(result).column = block.getByPosition(result).type->createColumnConstWithDefaultValue(block.rows());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const DataTypePtr & return_type = block.getByPosition(result).type;
|
const DataTypePtr & return_type = block.getByPosition(result).type;
|
||||||
const DataTypePtr & elem_type = static_cast<const DataTypeArray &>(*return_type).getNestedType();
|
const DataTypePtr & elem_type = static_cast<const DataTypeArray &>(*return_type).getNestedType();
|
||||||
|
|
||||||
@ -91,8 +98,7 @@ void FunctionArray::executeImpl(Block & block, const ColumnNumbers & arguments,
|
|||||||
columns[i] = columns_holder[i].get();
|
columns[i] = columns_holder[i].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create and fill the result array.
|
/// Create and fill the result array.
|
||||||
*/
|
|
||||||
|
|
||||||
auto out = ColumnArray::create(elem_type->createColumn());
|
auto out = ColumnArray::create(elem_type->createColumn());
|
||||||
IColumn & out_data = out->getData();
|
IColumn & out_data = out->getData();
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
Array(Nothing), Const(size = 1, Array(size = 1, UInt64(size = 1), Nothing(size = 0)))
|
||||||
|
Array(Array(Array(Nothing))), Const(size = 1, Array(size = 1, UInt64(size = 1), Array(size = 1, UInt64(size = 1), Array(size = 1, UInt64(size = 1), Nothing(size = 0)))))
|
||||||
|
Array(Array(UInt8)), Const(size = 1, Array(size = 1, UInt64(size = 1), Array(size = 2, UInt64(size = 2), UInt8(size = 1))))
|
@ -0,0 +1,3 @@
|
|||||||
|
SELECT dumpColumnStructure([]);
|
||||||
|
SELECT dumpColumnStructure([[[]]]);
|
||||||
|
SELECT DISTINCT dumpColumnStructure([[], [1]]) FROM numbers(2);
|
Loading…
Reference in New Issue
Block a user