mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Flip the condition column in arrayFill
This commit is contained in:
parent
b87fe27cd6
commit
79a27ece1a
@ -47,6 +47,8 @@ struct ArrayFillImpl
|
||||
{
|
||||
if (end == array_end || fill[end + 1] != fill[begin]) {
|
||||
if (fill[begin])
|
||||
out_data.insertRangeFrom(in_data, begin, end + 1 - begin);
|
||||
else
|
||||
{
|
||||
if constexpr (Reverse)
|
||||
{
|
||||
@ -63,8 +65,6 @@ struct ArrayFillImpl
|
||||
out_data.insertManyFrom(in_data, begin - 1, end + 1 - begin);
|
||||
}
|
||||
}
|
||||
else
|
||||
out_data.insertRangeFrom(in_data, begin, end + 1 - begin);
|
||||
|
||||
begin = end + 1;
|
||||
}
|
||||
@ -81,29 +81,27 @@ struct ArrayFillImpl
|
||||
throw Exception("Unexpected type of cut column", ErrorCodes::ILLEGAL_COLUMN);
|
||||
|
||||
if (column_fill_const->getValue<UInt8>())
|
||||
{
|
||||
size_t array_begin = 0;
|
||||
size_t array_end = 0;
|
||||
|
||||
out_data.reserve(in_data.size());
|
||||
|
||||
for (size_t i = 0; i < in_offsets.size(); ++i)
|
||||
{
|
||||
array_end = in_offsets[i] - 1;
|
||||
|
||||
if constexpr (Reverse)
|
||||
out_data.insertManyFrom(in_data, array_end, array_end + 1 - array_begin);
|
||||
else
|
||||
out_data.insertManyFrom(in_data, array_begin, array_end + 1 - array_begin);
|
||||
|
||||
array_begin = array_end + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
return ColumnArray::create(
|
||||
array.getDataPtr(),
|
||||
array.getOffsetsPtr()
|
||||
);
|
||||
|
||||
size_t array_begin = 0;
|
||||
size_t array_end = 0;
|
||||
|
||||
out_data.reserve(in_data.size());
|
||||
|
||||
for (size_t i = 0; i < in_offsets.size(); ++i)
|
||||
{
|
||||
array_end = in_offsets[i] - 1;
|
||||
|
||||
if constexpr (Reverse)
|
||||
out_data.insertManyFrom(in_data, array_end, array_end + 1 - array_begin);
|
||||
else
|
||||
out_data.insertManyFrom(in_data, array_begin, array_end + 1 - array_begin);
|
||||
|
||||
array_begin = array_end + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ColumnArray::create(
|
||||
|
@ -1,9 +1,9 @@
|
||||
[1,2,3,11,12,13,4,5,6,14,15,16]
|
||||
[1,2,3,11,12,13,4,5,6,14,15,16]
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1]
|
||||
[16,16,16,16,16,16,16,16,16,16,16,16]
|
||||
[1,1,1,11,12,13,13,13,13,14,15,16]
|
||||
[11,11,11,11,12,13,14,14,14,14,15,16]
|
||||
[1,2,3,11,12,13,4,5,6,14,15,16]
|
||||
[1,2,3,11,12,13,4,5,6,14,15,16]
|
||||
[1,2,3,3,3,3,4,5,6,6,6,6]
|
||||
[1,2,3,4,4,4,4,5,6,16,16,16]
|
||||
[1,1,3,11,12,12,12,5,6,14,14,14]
|
||||
[1,3,3,11,12,5,5,5,6,14,NULL,NULL]
|
||||
[1,1,3,11,11,11,11,5,6,14,14,14]
|
||||
|
@ -5,7 +5,7 @@ SELECT arrayReverseFill(x -> 1, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16]);
|
||||
|
||||
SELECT arrayFill(x -> x < 10, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16]);
|
||||
SELECT arrayReverseFill(x -> x < 10, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16]);
|
||||
SELECT arrayFill(x -> isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]);
|
||||
SELECT arrayReverseFill(x -> isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]);
|
||||
SELECT arrayFill((x, y) -> y, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16], [1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1]);
|
||||
SELECT arrayReverseFill((x, y) -> y, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16], [1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1]);
|
||||
SELECT arrayFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]);
|
||||
SELECT arrayReverseFill(x -> not isNull(x), [1, null, 3, 11, 12, null, null, 5, 6, 14, null, null]);
|
||||
SELECT arrayFill((x, y) -> y, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16], [0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0]);
|
||||
SELECT arrayReverseFill((x, y) -> y, [1, 2, 3, 11, 12, 13, 4, 5, 6, 14, 15, 16], [0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0]);
|
||||
|
Loading…
Reference in New Issue
Block a user