dbms: higher order functions: added support for constant expressions [#METR-17014].

This commit is contained in:
Alexey Milovidov 2015-06-28 09:25:12 +03:00
parent 6b82289af4
commit cdf90e9510
3 changed files with 1328 additions and 14 deletions

View File

@ -41,7 +41,9 @@ struct ArrayMapImpl
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
return new ColumnArray(mapped, array->getOffsetsColumn());
return mapped->isConst()
? new ColumnArray(dynamic_cast<const IColumnConst &>(*mapped).convertToFullColumn(), array->getOffsetsColumn())
: new ColumnArray(mapped, array->getOffsetsColumn());
}
};
@ -59,9 +61,20 @@ struct ArrayFilterImpl
/// Если массивов несколько, сюда передается первый.
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
ColumnVector<UInt8> * column_filter = typeid_cast<ColumnVector<UInt8> *>(&*mapped);
const ColumnVector<UInt8> * column_filter = typeid_cast<const ColumnVector<UInt8> *>(&*mapped);
if (!column_filter)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
{
const ColumnConstUInt8 * column_filter_const = typeid_cast<const ColumnConstUInt8 *>(&*mapped);
if (!column_filter_const)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
if (column_filter_const->getData())
return array->clone();
else
return new ColumnArray(array->getDataPtr()->cloneEmpty(), new ColumnArray::ColumnOffsets_t(array->size(), 0));
}
const IColumn::Filter & filter = column_filter->getData();
ColumnPtr filtered = array->getData().filter(filter);
@ -100,9 +113,34 @@ struct ArrayCountImpl
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
ColumnVector<UInt8> * column_filter = typeid_cast<ColumnVector<UInt8> *>(&*mapped);
const ColumnVector<UInt8> * column_filter = typeid_cast<const ColumnVector<UInt8> *>(&*mapped);
if (!column_filter)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
{
const ColumnConstUInt8 * column_filter_const = typeid_cast<const ColumnConstUInt8 *>(&*mapped);
if (!column_filter_const)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
if (column_filter_const->getData())
{
const IColumn::Offsets_t & offsets = array->getOffsets();
ColumnVector<UInt32> * out_column = new ColumnVector<UInt32>(offsets.size());
ColumnPtr out_column_ptr = out_column;
ColumnVector<UInt32>::Container_t & out_counts = out_column->getData();
size_t pos = 0;
for (size_t i = 0; i < offsets.size(); ++i)
{
out_counts[i] = offsets[i] - pos;
pos = offsets[i];
}
return out_column_ptr;
}
else
return new ColumnConstUInt32(array->size(), 0);
}
const IColumn::Filter & filter = column_filter->getData();
const IColumn::Offsets_t & offsets = array->getOffsets();
@ -139,9 +177,34 @@ struct ArrayExistsImpl
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
ColumnVector<UInt8> * column_filter = typeid_cast<ColumnVector<UInt8> *>(&*mapped);
const ColumnVector<UInt8> * column_filter = typeid_cast<const ColumnVector<UInt8> *>(&*mapped);
if (!column_filter)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
{
const ColumnConstUInt8 * column_filter_const = typeid_cast<const ColumnConstUInt8 *>(&*mapped);
if (!column_filter_const)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
if (column_filter_const->getData())
{
const IColumn::Offsets_t & offsets = array->getOffsets();
ColumnVector<UInt8> * out_column = new ColumnVector<UInt8>(offsets.size());
ColumnPtr out_column_ptr = out_column;
ColumnVector<UInt8>::Container_t & out_exists = out_column->getData();
size_t pos = 0;
for (size_t i = 0; i < offsets.size(); ++i)
{
out_exists[i] = offsets[i] - pos > 0;
pos = offsets[i];
}
return out_column_ptr;
}
else
return new ColumnConstUInt8(array->size(), 0);
}
const IColumn::Filter & filter = column_filter->getData();
const IColumn::Offsets_t & offsets = array->getOffsets();
@ -182,9 +245,34 @@ struct ArrayAllImpl
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
ColumnVector<UInt8> * column_filter = typeid_cast<ColumnVector<UInt8> *>(&*mapped);
const ColumnVector<UInt8> * column_filter = typeid_cast<const ColumnVector<UInt8> *>(&*mapped);
if (!column_filter)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
{
const ColumnConstUInt8 * column_filter_const = typeid_cast<const ColumnConstUInt8 *>(&*mapped);
if (!column_filter_const)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
if (column_filter_const->getData())
return new ColumnConstUInt8(array->size(), 1);
else
{
const IColumn::Offsets_t & offsets = array->getOffsets();
ColumnVector<UInt8> * out_column = new ColumnVector<UInt8>(offsets.size());
ColumnPtr out_column_ptr = out_column;
ColumnVector<UInt8>::Container_t & out_all = out_column->getData();
size_t pos = 0;
for (size_t i = 0; i < offsets.size(); ++i)
{
out_all[i] = offsets[i] == pos;
pos = offsets[i];
}
return out_column_ptr;
}
}
const IColumn::Filter & filter = column_filter->getData();
const IColumn::Offsets_t & offsets = array->getOffsets();
@ -245,7 +333,27 @@ struct ArraySumImpl
const ColumnVector<Element> * column = typeid_cast<const ColumnVector<Element> *>(&*mapped);
if (!column)
return false;
{
const ColumnConst<Element> * column_const = typeid_cast<const ColumnConst<Element> *>(&*mapped);
if (!column_const)
return false;
const Element x = column_const->getData();
ColumnVector<Result> * res_column = new ColumnVector<Result>(offsets.size());
res_ptr = res_column;
typename ColumnVector<Result>::Container_t & res = res_column->getData();
size_t pos = 0;
for (size_t i = 0; i < offsets.size(); ++i)
{
res[i] = x * (offsets[i] - pos);
pos = offsets[i];
}
return true;
}
const typename ColumnVector<Element>::Container_t & data = column->getData();
ColumnVector<Result> * res_column = new ColumnVector<Result>(offsets.size());
@ -300,9 +408,41 @@ struct ArrayFirstImpl
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
auto column_filter = typeid_cast<ColumnVector<UInt8> *>(&*mapped);
auto column_filter = typeid_cast<const ColumnVector<UInt8> *>(&*mapped);
if (!column_filter)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
{
const ColumnConstUInt8 * column_filter_const = typeid_cast<const ColumnConstUInt8 *>(&*mapped);
if (!column_filter_const)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
if (column_filter_const->getData())
{
const auto & offsets = array->getOffsets();
const auto & data = array->getData();
ColumnPtr out{data.cloneEmpty()};
size_t pos{};
for (size_t i = 0; i < offsets.size(); ++i)
{
if (offsets[i] - pos > 0)
out->insert(data[pos]);
else
out->insertDefault();
pos = offsets[i];
}
return out;
}
else
{
ColumnPtr out{array->getData().cloneEmpty()};
out->insertDefault();
return out->replicate(IColumn::Offsets_t(1, array->size()));
}
}
const auto & filter = column_filter->getData();
const auto & offsets = array->getOffsets();
@ -345,9 +485,34 @@ struct ArrayFirstIndexImpl
static ColumnPtr execute(const ColumnArray * array, ColumnPtr mapped)
{
auto column_filter = typeid_cast<ColumnVector<UInt8> *>(&*mapped);
auto column_filter = typeid_cast<const ColumnVector<UInt8> *>(&*mapped);
if (!column_filter)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
{
const ColumnConstUInt8 * column_filter_const = typeid_cast<const ColumnConstUInt8 *>(&*mapped);
if (!column_filter_const)
throw Exception("Unexpected type of filter column", ErrorCodes::ILLEGAL_COLUMN);
if (column_filter_const->getData())
{
const auto & offsets = array->getOffsets();
auto out_column = new ColumnVector<UInt32>{offsets.size()};
ColumnPtr out_column_ptr{out_column};
auto & out_index = out_column->getData();
size_t pos{};
for (size_t i = 0; i < offsets.size(); ++i)
{
out_index[i] = offsets[i] - pos > 0;
pos = offsets[i];
}
return out_column_ptr;
}
else
return new ColumnConstUInt32(array->size(), 0);
}
const auto & filter = column_filter->getData();
const auto & offsets = array->getOffsets();

View File

@ -0,0 +1,914 @@
---map--
[]
[123,123,123]
[]
[123]
[123,123]
[123,123,123]
[123,123,123,123]
[123,123,123,123,123]
[123,123,123,123,123,123]
[123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123,123]
---filter--
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[1,2,3]
[]
[0]
[0,1]
[0,1,2]
[0,1,2,3]
[0,1,2,3,4]
[0,1,2,3,4,5]
[0,1,2,3,4,5,6]
[0,1,2,3,4,5,6,7]
[0,1,2,3,4,5,6,7,8]
---count---
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
1
2
3
4
5
6
7
8
9
---sum---
0
0
0
0
0
0
0
0
0
0
0
0
0
30
0
10
20
30
40
50
60
70
80
90
---all---
1
0
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
---exists---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---first---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
---first index---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---map--
[]
[123,123,123]
[]
[123]
[123,123]
[123,123,123]
[123,123,123,123]
[123,123,123,123,123]
[123,123,123,123,123,123]
[123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123,123]
---filter--
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[1,2,3]
[]
[0]
[0,1]
[0,1,2]
[0,1,2,3]
[0,1,2,3,4]
[0,1,2,3,4,5]
[0,1,2,3,4,5,6]
[0,1,2,3,4,5,6,7]
[0,1,2,3,4,5,6,7,8]
---count---
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
1
2
3
4
5
6
7
8
9
---sum---
0
0
0
0
0
0
0
0
0
0
0
0
0
30
0
10
20
30
40
50
60
70
80
90
---all---
1
0
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
---exists---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---first---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
---first index---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---map--
[]
[123,123,123]
[]
[123]
[123,123]
[123,123,123]
[123,123,123,123]
[123,123,123,123,123]
[123,123,123,123,123,123]
[123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123,123]
---filter--
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
['1','2','3']
[]
['0']
['0','1']
['0','1','2']
['0','1','2','3']
['0','1','2','3','4']
['0','1','2','3','4','5']
['0','1','2','3','4','5','6']
['0','1','2','3','4','5','6','7']
['0','1','2','3','4','5','6','7','8']
---count---
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
1
2
3
4
5
6
7
8
9
---sum---
0
0
0
0
0
0
0
0
0
0
0
0
0
30
0
10
20
30
40
50
60
70
80
90
---all---
1
0
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
---exists---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---first---
1
0
0
0
0
0
0
0
0
0
---first index---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---map--
[]
[123,123,123]
[]
[123]
[123,123]
[123,123,123]
[123,123,123,123]
[123,123,123,123,123]
[123,123,123,123,123,123]
[123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123]
[123,123,123,123,123,123,123,123,123]
---filter--
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
['1','2','3']
[]
['0']
['0','1']
['0','1','2']
['0','1','2','3']
['0','1','2','3','4']
['0','1','2','3','4','5']
['0','1','2','3','4','5','6']
['0','1','2','3','4','5','6','7']
['0','1','2','3','4','5','6','7','8']
---count---
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
1
2
3
4
5
6
7
8
9
---sum---
0
0
0
0
0
0
0
0
0
0
0
0
0
30
0
10
20
30
40
50
60
70
80
90
---all---
1
0
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
---exists---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
---first---
1
0
0
0
0
0
0
0
0
0
---first index---
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
--- ---
[]
[1]
[0,0]
[1,1,1]
[0,0,0,0]
[1,1,1,1,1]
[0,0,0,0,0,0]
[1,1,1,1,1,1,1]
[0,0,0,0,0,0,0,0]
[1,1,1,1,1,1,1,1,1]
[]
[0]
[]
[0,1,2]
[]
[0,1,2,3,4]
[]
[0,1,2,3,4,5,6]
[]
[0,1,2,3,4,5,6,7,8]
0
1
0
3
0
5
0
7
0
9
0
1
0
3
0
5
0
7
0
9
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
--- ---
[]
[1]
[0,0]
[1,1,1]
[0,0,0,0]
[1,1,1,1,1]
[0,0,0,0,0,0]
[1,1,1,1,1,1,1]
[0,0,0,0,0,0,0,0]
[1,1,1,1,1,1,1,1,1]
[]
['0']
[]
['0','1','2']
[]
['0','1','2','3','4']
[]
['0','1','2','3','4','5','6']
[]
['0','1','2','3','4','5','6','7','8']
0
1
0
3
0
5
0
7
0
9
0
1
0
3
0
5
0
7
0
9
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1

View File

@ -0,0 +1,235 @@
SELECT '---map--';
SELECT arrayMap(x -> 123, emptyArrayUInt8());
SELECT arrayMap(x -> 123, [1, 2, 3]);
SELECT arrayMap(x -> 123, range(number)) FROM system.numbers LIMIT 10;
SELECT '---filter--';
SELECT arrayFilter(x -> 0, emptyArrayUInt8());
SELECT arrayFilter(x -> 0, [1, 2, 3]);
SELECT arrayFilter(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFilter(x -> 1, emptyArrayUInt8());
SELECT arrayFilter(x -> 1, [1, 2, 3]);
SELECT arrayFilter(x -> 1, range(number)) FROM system.numbers LIMIT 10;
SELECT '---count---';
SELECT arrayCount(x -> 0, emptyArrayUInt8());
SELECT arrayCount(x -> 0, [1, 2, 3]);
SELECT arrayCount(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayCount(x -> 1, emptyArrayUInt8());
SELECT arrayCount(x -> 1, [1, 2, 3]);
SELECT arrayCount(x -> 1, range(number)) FROM system.numbers LIMIT 10;
SELECT '---sum---';
SELECT arraySum(x -> 0, emptyArrayUInt8());
SELECT arraySum(x -> 0, [1, 2, 3]);
SELECT arraySum(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arraySum(x -> 10, emptyArrayUInt8());
SELECT arraySum(x -> 10, [1, 2, 3]);
SELECT arraySum(x -> 10, range(number)) FROM system.numbers LIMIT 10;
SELECT '---all---';
SELECT arrayAll(x -> 0, emptyArrayUInt8());
SELECT arrayAll(x -> 0, [1, 2, 3]);
SELECT arrayAll(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayAll(x -> 1, emptyArrayUInt8());
SELECT arrayAll(x -> 1, [1, 2, 3]);
SELECT arrayAll(x -> 1, range(number)) FROM system.numbers LIMIT 10;
SELECT '---exists---';
SELECT arrayExists(x -> 0, emptyArrayUInt8());
SELECT arrayExists(x -> 0, [1, 2, 3]);
SELECT arrayExists(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayExists(x -> 1, emptyArrayUInt8());
SELECT arrayExists(x -> 1, [1, 2, 3]);
SELECT arrayExists(x -> 1, range(number)) FROM system.numbers LIMIT 10;
SELECT '---first---';
SELECT arrayFirst(x -> 0, emptyArrayUInt8());
SELECT arrayFirst(x -> 0, [1, 2, 3]);
SELECT arrayFirst(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFirst(x -> 1, emptyArrayUInt8());
SELECT arrayFirst(x -> 1, [1, 2, 3]);
SELECT arrayFirst(x -> 1, range(number)) FROM system.numbers LIMIT 10;
SELECT '---first index---';
SELECT arrayFirstIndex(x -> 0, emptyArrayUInt8());
SELECT arrayFirstIndex(x -> 0, [1, 2, 3]);
SELECT arrayFirstIndex(x -> 0, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFirstIndex(x -> 1, emptyArrayUInt8());
SELECT arrayFirstIndex(x -> 1, [1, 2, 3]);
SELECT arrayFirstIndex(x -> 1, range(number)) FROM system.numbers LIMIT 10;
SELECT '---map--';
SELECT arrayMap(x -> materialize(123), emptyArrayUInt8());
SELECT arrayMap(x -> materialize(123), [1, 2, 3]);
SELECT arrayMap(x -> materialize(123), range(number)) FROM system.numbers LIMIT 10;
SELECT '---filter--';
SELECT arrayFilter(x -> materialize(0), emptyArrayUInt8());
SELECT arrayFilter(x -> materialize(0), [1, 2, 3]);
SELECT arrayFilter(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFilter(x -> materialize(1), emptyArrayUInt8());
SELECT arrayFilter(x -> materialize(1), [1, 2, 3]);
SELECT arrayFilter(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
SELECT '---count---';
SELECT arrayCount(x -> materialize(0), emptyArrayUInt8());
SELECT arrayCount(x -> materialize(0), [1, 2, 3]);
SELECT arrayCount(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arrayCount(x -> materialize(1), emptyArrayUInt8());
SELECT arrayCount(x -> materialize(1), [1, 2, 3]);
SELECT arrayCount(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
SELECT '---sum---';
SELECT arraySum(x -> materialize(0), emptyArrayUInt8());
SELECT arraySum(x -> materialize(0), [1, 2, 3]);
SELECT arraySum(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arraySum(x -> materialize(10), emptyArrayUInt8());
SELECT arraySum(x -> materialize(10), [1, 2, 3]);
SELECT arraySum(x -> materialize(10), range(number)) FROM system.numbers LIMIT 10;
SELECT '---all---';
SELECT arrayAll(x -> materialize(0), emptyArrayUInt8());
SELECT arrayAll(x -> materialize(0), [1, 2, 3]);
SELECT arrayAll(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arrayAll(x -> materialize(1), emptyArrayUInt8());
SELECT arrayAll(x -> materialize(1), [1, 2, 3]);
SELECT arrayAll(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
SELECT '---exists---';
SELECT arrayExists(x -> materialize(0), emptyArrayUInt8());
SELECT arrayExists(x -> materialize(0), [1, 2, 3]);
SELECT arrayExists(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arrayExists(x -> materialize(1), emptyArrayUInt8());
SELECT arrayExists(x -> materialize(1), [1, 2, 3]);
SELECT arrayExists(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
SELECT '---first---';
SELECT arrayFirst(x -> materialize(0), emptyArrayUInt8());
SELECT arrayFirst(x -> materialize(0), [1, 2, 3]);
SELECT arrayFirst(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFirst(x -> materialize(1), emptyArrayUInt8());
SELECT arrayFirst(x -> materialize(1), [1, 2, 3]);
SELECT arrayFirst(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
SELECT '---first index---';
SELECT arrayFirstIndex(x -> materialize(0), emptyArrayUInt8());
SELECT arrayFirstIndex(x -> materialize(0), [1, 2, 3]);
SELECT arrayFirstIndex(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFirstIndex(x -> materialize(1), emptyArrayUInt8());
SELECT arrayFirstIndex(x -> materialize(1), [1, 2, 3]);
SELECT arrayFirstIndex(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
SELECT '---map--';
SELECT arrayMap(x -> 123, emptyArrayString());
SELECT arrayMap(x -> 123, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayMap(x -> 123, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---filter--';
SELECT arrayFilter(x -> 0, emptyArrayString());
SELECT arrayFilter(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFilter(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFilter(x -> 1, emptyArrayString());
SELECT arrayFilter(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFilter(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---count---';
SELECT arrayCount(x -> 0, emptyArrayString());
SELECT arrayCount(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayCount(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayCount(x -> 1, emptyArrayString());
SELECT arrayCount(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayCount(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---sum---';
SELECT arraySum(x -> 0, emptyArrayString());
SELECT arraySum(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arraySum(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arraySum(x -> 10, emptyArrayString());
SELECT arraySum(x -> 10, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arraySum(x -> 10, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---all---';
SELECT arrayAll(x -> 0, emptyArrayString());
SELECT arrayAll(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayAll(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayAll(x -> 1, emptyArrayString());
SELECT arrayAll(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayAll(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---exists---';
SELECT arrayExists(x -> 0, emptyArrayString());
SELECT arrayExists(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayExists(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayExists(x -> 1, emptyArrayString());
SELECT arrayExists(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayExists(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---first---';
SELECT arrayFirst(x -> 0, emptyArrayString());
SELECT arrayFirst(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirst(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFirst(x -> 1, emptyArrayString());
SELECT arrayFirst(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirst(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---first index---';
SELECT arrayFirstIndex(x -> 0, emptyArrayString());
SELECT arrayFirstIndex(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirstIndex(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFirstIndex(x -> 1, emptyArrayString());
SELECT arrayFirstIndex(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirstIndex(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---map--';
SELECT arrayMap(x -> materialize(123), emptyArrayString());
SELECT arrayMap(x -> materialize(123), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayMap(x -> materialize(123), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---filter--';
SELECT arrayFilter(x -> materialize(0), emptyArrayString());
SELECT arrayFilter(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFilter(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFilter(x -> materialize(1), emptyArrayString());
SELECT arrayFilter(x -> materialize(1), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFilter(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---count---';
SELECT arrayCount(x -> materialize(0), emptyArrayString());
SELECT arrayCount(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayCount(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayCount(x -> materialize(1), emptyArrayString());
SELECT arrayCount(x -> materialize(1), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayCount(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---sum---';
SELECT arraySum(x -> materialize(0), emptyArrayString());
SELECT arraySum(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arraySum(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arraySum(x -> materialize(10), emptyArrayString());
SELECT arraySum(x -> materialize(10), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arraySum(x -> materialize(10), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---all---';
SELECT arrayAll(x -> materialize(0), emptyArrayString());
SELECT arrayAll(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayAll(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayAll(x -> materialize(1), emptyArrayString());
SELECT arrayAll(x -> materialize(1), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayAll(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---exists---';
SELECT arrayExists(x -> materialize(0), emptyArrayString());
SELECT arrayExists(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayExists(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayExists(x -> materialize(1), emptyArrayString());
SELECT arrayExists(x -> materialize(1), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayExists(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---first---';
SELECT arrayFirst(x -> materialize(0), emptyArrayString());
SELECT arrayFirst(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirst(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFirst(x -> materialize(1), emptyArrayString());
SELECT arrayFirst(x -> materialize(1), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirst(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '---first index---';
SELECT arrayFirstIndex(x -> materialize(0), emptyArrayString());
SELECT arrayFirstIndex(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirstIndex(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFirstIndex(x -> materialize(1), emptyArrayString());
SELECT arrayFirstIndex(x -> materialize(1), arrayMap(x -> toString(x), [1, 2, 3]));
SELECT arrayFirstIndex(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT '--- ---';
SELECT arrayMap(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFilter(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayCount(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arraySum(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayAll(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayExists(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFirst(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT arrayFirstIndex(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
SELECT '--- ---';
SELECT arrayMap(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFilter(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayCount(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arraySum(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayAll(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayExists(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFirst(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
SELECT arrayFirstIndex(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;