mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
tests wip
This commit is contained in:
parent
0297a598b9
commit
c810db2a01
@ -62,7 +62,6 @@ struct ArrayCumSumImpl
|
|||||||
|
|
||||||
static DataTypePtr getReturnType(const DataTypePtr & expression_return, const DataTypePtr & /*array_element*/)
|
static DataTypePtr getReturnType(const DataTypePtr & expression_return, const DataTypePtr & /*array_element*/)
|
||||||
{
|
{
|
||||||
//return std::make_shared<DataTypeArray>(array_element);
|
|
||||||
if (checkDataType<DataTypeUInt8>(&*expression_return) ||
|
if (checkDataType<DataTypeUInt8>(&*expression_return) ||
|
||||||
checkDataType<DataTypeUInt16>(&*expression_return) ||
|
checkDataType<DataTypeUInt16>(&*expression_return) ||
|
||||||
checkDataType<DataTypeUInt32>(&*expression_return) ||
|
checkDataType<DataTypeUInt32>(&*expression_return) ||
|
||||||
@ -79,7 +78,7 @@ struct ArrayCumSumImpl
|
|||||||
checkDataType<DataTypeFloat64>(&*expression_return))
|
checkDataType<DataTypeFloat64>(&*expression_return))
|
||||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeFloat64>());
|
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeFloat64>());
|
||||||
|
|
||||||
throw Exception("arraySum cannot add values of type " + expression_return->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
throw Exception("arrayCumSum cannot add values of type " + expression_return->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +89,7 @@ struct ArrayCumSumImpl
|
|||||||
if (!column)
|
if (!column)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*if (!column)
|
if (!column)
|
||||||
{
|
{
|
||||||
const ColumnConst * column_const = checkAndGetColumnConst<ColumnVector<Element>>(&*mapped);
|
const ColumnConst * column_const = checkAndGetColumnConst<ColumnVector<Element>>(&*mapped);
|
||||||
|
|
||||||
@ -99,9 +98,10 @@ struct ArrayCumSumImpl
|
|||||||
|
|
||||||
const Element x = column_const->template getValue<Element>();
|
const Element x = column_const->template getValue<Element>();
|
||||||
|
|
||||||
auto res_nested = ColumnVector<Result>::create();
|
i // create output column
|
||||||
ColumnVector<Result>::Container & res_values = res_nested->getData();
|
auto res_nested = ColumnVector<Result>::create();
|
||||||
res_values.resize(offsets.size());
|
typename ColumnVector<Result>::Container & res_values = res_nested->getData();
|
||||||
|
res_values.resize(data.size());
|
||||||
|
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
for (size_t i = 0; i < offsets.size(); ++i)
|
for (size_t i = 0; i < offsets.size(); ++i)
|
||||||
@ -115,7 +115,7 @@ struct ArrayCumSumImpl
|
|||||||
|
|
||||||
res_ptr = ColumnArray::create(std::move(res_nested), offsets);
|
res_ptr = ColumnArray::create(std::move(res_nested), offsets);
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
const IColumn::Offsets & offsets = array.getOffsets();
|
const IColumn::Offsets & offsets = array.getOffsets();
|
||||||
const typename ColumnVector<Element>::Container & data = column->getData();
|
const typename ColumnVector<Element>::Container & data = column->getData();
|
||||||
|
@ -51,6 +51,13 @@ SELECT arrayFirstIndex(x -> 0, range(number)) FROM system.numbers LIMIT 10;
|
|||||||
SELECT arrayFirstIndex(x -> 1, emptyArrayUInt8());
|
SELECT arrayFirstIndex(x -> 1, emptyArrayUInt8());
|
||||||
SELECT arrayFirstIndex(x -> 1, [1, 2, 3]);
|
SELECT arrayFirstIndex(x -> 1, [1, 2, 3]);
|
||||||
SELECT arrayFirstIndex(x -> 1, range(number)) FROM system.numbers LIMIT 10;
|
SELECT arrayFirstIndex(x -> 1, range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT '---cumsum---';
|
||||||
|
SELECT arrayCumSum(x -> 0, emptyArrayUInt8());
|
||||||
|
SELECT arrayCumSum(x -> 0, [1, 2, 3]);
|
||||||
|
SELECT arrayCumSum(x -> 0, range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT arrayCumSum(x -> 10, emptyArrayUInt8());
|
||||||
|
SELECT arrayCumSum(x -> 10, [1, 2, 3]);
|
||||||
|
SELECT arrayCumSum(x -> 10, range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
|
||||||
SELECT '---map--';
|
SELECT '---map--';
|
||||||
SELECT arrayMap(x -> materialize(123), emptyArrayUInt8());
|
SELECT arrayMap(x -> materialize(123), emptyArrayUInt8());
|
||||||
@ -105,6 +112,13 @@ SELECT arrayFirstIndex(x -> materialize(0), range(number)) FROM system.numbers L
|
|||||||
SELECT arrayFirstIndex(x -> materialize(1), emptyArrayUInt8());
|
SELECT arrayFirstIndex(x -> materialize(1), emptyArrayUInt8());
|
||||||
SELECT arrayFirstIndex(x -> materialize(1), [1, 2, 3]);
|
SELECT arrayFirstIndex(x -> materialize(1), [1, 2, 3]);
|
||||||
SELECT arrayFirstIndex(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
|
SELECT arrayFirstIndex(x -> materialize(1), range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT '--cumsum---';
|
||||||
|
SELECT arrayCumSum(x -> materialize(0), emptyArrayUInt8());
|
||||||
|
SELECT arrayCumSum(x -> materialize(0), [1, 2, 3]);
|
||||||
|
SELECT arrayCumSum(x -> materialize(0), range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT arrayCumSum(x -> materialize(10), emptyArrayUInt8());
|
||||||
|
SELECT arrayCumSum(x -> materialize(10), [1, 2, 3]);
|
||||||
|
SELECT arrayCumSum(x -> materialize(10), range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
|
||||||
SELECT '---map--';
|
SELECT '---map--';
|
||||||
SELECT arrayMap(x -> 123, emptyArrayString());
|
SELECT arrayMap(x -> 123, emptyArrayString());
|
||||||
@ -159,6 +173,13 @@ SELECT arrayFirstIndex(x -> 0, arrayMap(x -> toString(x), range(number))) FROM s
|
|||||||
SELECT arrayFirstIndex(x -> 1, emptyArrayString());
|
SELECT arrayFirstIndex(x -> 1, emptyArrayString());
|
||||||
SELECT arrayFirstIndex(x -> 1, arrayMap(x -> toString(x), [1, 2, 3]));
|
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 arrayFirstIndex(x -> 1, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT '---cumsum---';
|
||||||
|
SELECT arrayCumSum(x -> 0, emptyArrayString());
|
||||||
|
SELECT arrayCumSum(x -> 0, arrayMap(x -> toString(x), [1, 2, 3]));
|
||||||
|
SELECT arrayCumSum(x -> 0, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT arrayCumSum(x -> 10, emptyArrayString());
|
||||||
|
SELECT arrayCumSum(x -> 10, arrayMap(x -> toString(x), [1, 2, 3]));
|
||||||
|
SELECT arrayCumSum(x -> 10, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
|
||||||
SELECT '---map--';
|
SELECT '---map--';
|
||||||
SELECT arrayMap(x -> materialize(123), emptyArrayString());
|
SELECT arrayMap(x -> materialize(123), emptyArrayString());
|
||||||
@ -213,7 +234,13 @@ SELECT arrayFirstIndex(x -> materialize(0), arrayMap(x -> toString(x), range(num
|
|||||||
SELECT arrayFirstIndex(x -> materialize(1), emptyArrayString());
|
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), [1, 2, 3]));
|
||||||
SELECT arrayFirstIndex(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
SELECT arrayFirstIndex(x -> materialize(1), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT '---cumsum---';
|
||||||
|
SELECT arrayCumSum(x -> materialize(0), emptyArrayString());
|
||||||
|
SELECT arrayCumSum(x -> materialize(0), arrayMap(x -> toString(x), [1, 2, 3]));
|
||||||
|
SELECT arrayCumSum(x -> materialize(0), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT arrayCumSum(x -> materialize(10), emptyArrayString());
|
||||||
|
SELECT arrayCumSum(x -> materialize(10), arrayMap(x -> toString(x), [1, 2, 3]));
|
||||||
|
SELECT arrayCumSum(x -> materialize(10), arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
|
||||||
SELECT '--- ---';
|
SELECT '--- ---';
|
||||||
SELECT arrayMap(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
|
SELECT arrayMap(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
|
||||||
@ -224,6 +251,7 @@ 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 arrayExists(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
|
||||||
SELECT arrayFirst(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 arrayFirstIndex(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT arrayCumSum(x -> number % 2, range(number)) FROM system.numbers LIMIT 10;
|
||||||
SELECT '--- ---';
|
SELECT '--- ---';
|
||||||
SELECT arrayMap(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
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 arrayFilter(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
@ -233,3 +261,4 @@ SELECT arrayAll(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM
|
|||||||
SELECT arrayExists(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 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;
|
SELECT arrayFirstIndex(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
SELECT arrayCumSum(x -> number % 2, arrayMap(x -> toString(x), range(number))) FROM system.numbers LIMIT 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user