mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
[chore] add test for arrayCumSumNonNegative.
Signed-off-by: clundro <859287553@qq.com>
This commit is contained in:
parent
c02882fd79
commit
447d6cf153
@ -30,11 +30,25 @@ struct ArrayCumSumNonNegativeImpl
|
||||
{
|
||||
WhichDataType which(expression_return);
|
||||
|
||||
if (which.isNativeUInt())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>());
|
||||
if (which.isUInt())
|
||||
{
|
||||
if (which.isNativeUInt())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>());
|
||||
if (which.isUInt256())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt256>());
|
||||
else
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt128>());
|
||||
}
|
||||
|
||||
if (which.isNativeInt())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeInt64>());
|
||||
if (which.isInt())
|
||||
{
|
||||
if (which.isNativeInt())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeInt64>());
|
||||
if (which.isInt256())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeInt256>());
|
||||
else
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeInt128>());
|
||||
}
|
||||
|
||||
if (which.isFloat())
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeFloat64>());
|
||||
@ -50,14 +64,14 @@ struct ArrayCumSumNonNegativeImpl
|
||||
return std::make_shared<DataTypeArray>(nested);
|
||||
}
|
||||
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"arrayCumSumNonNegativeImpl cannot add values of type {}", expression_return->getName());
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "arrayCumSumNonNegativeImpl cannot add values of type {}", expression_return->getName());
|
||||
}
|
||||
|
||||
|
||||
template <typename Src, typename Dst>
|
||||
static void NO_SANITIZE_UNDEFINED implVector(
|
||||
size_t size, const IColumn::Offset * __restrict offsets, Dst * __restrict res_values, const Src * __restrict src_values)
|
||||
static void NO_SANITIZE_UNDEFINED
|
||||
implVector(size_t size, const IColumn::Offset * __restrict offsets, Dst * __restrict res_values, const Src * __restrict src_values)
|
||||
{
|
||||
size_t pos = 0;
|
||||
for (const auto * end = offsets + size; offsets < end; ++offsets)
|
||||
@ -100,7 +114,6 @@ struct ArrayCumSumNonNegativeImpl
|
||||
implVector(offsets.size(), offsets.data(), res_values.data(), data.data());
|
||||
res_ptr = ColumnArray::create(std::move(res_nested), array.getOffsetsPtr());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static ColumnPtr execute(const ColumnArray & array, ColumnPtr mapped)
|
||||
@ -108,28 +121,25 @@ struct ArrayCumSumNonNegativeImpl
|
||||
ColumnPtr res;
|
||||
|
||||
mapped = mapped->convertToFullColumnIfConst();
|
||||
if (executeType< UInt8 , UInt64>(mapped, array, res) ||
|
||||
executeType< UInt16, UInt64>(mapped, array, res) ||
|
||||
executeType< UInt32, UInt64>(mapped, array, res) ||
|
||||
executeType< UInt64, UInt64>(mapped, array, res) ||
|
||||
executeType< Int8 , Int64>(mapped, array, res) ||
|
||||
executeType< Int16, Int64>(mapped, array, res) ||
|
||||
executeType< Int32, Int64>(mapped, array, res) ||
|
||||
executeType< Int64, Int64>(mapped, array, res) ||
|
||||
executeType<Float32,Float64>(mapped, array, res) ||
|
||||
executeType<Float64,Float64>(mapped, array, res) ||
|
||||
executeType<Decimal32, Decimal128>(mapped, array, res) ||
|
||||
executeType<Decimal64, Decimal128>(mapped, array, res) ||
|
||||
executeType<Decimal128, Decimal128>(mapped, array, res) ||
|
||||
executeType<Decimal256, Decimal256>(mapped, array, res))
|
||||
if (executeType<UInt8, UInt64>(mapped, array, res) || executeType<UInt16, UInt64>(mapped, array, res)
|
||||
|| executeType<UInt32, UInt64>(mapped, array, res) || executeType<UInt64, UInt64>(mapped, array, res)
|
||||
|| executeType<UInt128, UInt128>(mapped, array, res) || executeType<UInt256, UInt256>(mapped, array, res)
|
||||
|| executeType<Int8, Int64>(mapped, array, res) || executeType<Int16, Int64>(mapped, array, res)
|
||||
|| executeType<Int32, Int64>(mapped, array, res) || executeType<Int64, Int64>(mapped, array, res)
|
||||
|| executeType<Int128, Int128>(mapped, array, res) || executeType<Int256, Int256>(mapped, array, res)
|
||||
|| executeType<Float32, Float64>(mapped, array, res) || executeType<Float64, Float64>(mapped, array, res)
|
||||
|| executeType<Decimal32, Decimal128>(mapped, array, res) || executeType<Decimal64, Decimal128>(mapped, array, res)
|
||||
|| executeType<Decimal128, Decimal128>(mapped, array, res) || executeType<Decimal256, Decimal256>(mapped, array, res))
|
||||
return res;
|
||||
else
|
||||
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Unexpected column for arrayCumSumNonNegativeImpl: {}", mapped->getName());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct NameArrayCumSumNonNegative { static constexpr auto name = "arrayCumSumNonNegative"; };
|
||||
struct NameArrayCumSumNonNegative
|
||||
{
|
||||
static constexpr auto name = "arrayCumSumNonNegative";
|
||||
};
|
||||
using FunctionArrayCumSumNonNegative = FunctionArrayMapped<ArrayCumSumNonNegativeImpl, NameArrayCumSumNonNegative>;
|
||||
|
||||
REGISTER_FUNCTION(ArrayCumSumNonNegative)
|
||||
|
@ -8,7 +8,6 @@ Array(UInt128)
|
||||
Array(Int128)
|
||||
Array(UInt256)
|
||||
Array(Int256)
|
||||
|
||||
[0,2]
|
||||
[0,2]
|
||||
[0,2]
|
||||
@ -16,4 +15,12 @@ Array(Int256)
|
||||
Array(Int128)
|
||||
Array(Int128)
|
||||
Array(Int256)
|
||||
Array(Int256)
|
||||
Array(Int256)
|
||||
[1,0]
|
||||
[1,0]
|
||||
[1,3]
|
||||
[1,3]
|
||||
Array(Int128)
|
||||
Array(Int256)
|
||||
Array(UInt128)
|
||||
Array(UInt256)
|
@ -16,4 +16,13 @@ SELECT arrayDifference([CAST('1', 'Int128'), 3]);
|
||||
SELECT toTypeName(arrayDifference([CAST('1', 'UInt128'), 3]));
|
||||
SELECT toTypeName(arrayDifference([CAST('1', 'Int128'), 3]));
|
||||
SELECT toTypeName(arrayDifference([CAST('1', 'UInt256'), 3]));
|
||||
SELECT toTypeName(arrayDifference([CAST('1', 'Int256'), 3]));
|
||||
SELECT toTypeName(arrayDifference([CAST('1', 'Int256'), 3]));
|
||||
|
||||
SELECT arrayCumSumNonNegative([CAST('1', 'Int128'), -2]);
|
||||
SELECT arrayCumSumNonNegative([CAST('1', 'Int256'), -2]);
|
||||
SELECT arrayCumSumNonNegative([CAST('1', 'UInt128'), 2]);
|
||||
SELECT arrayCumSumNonNegative([CAST('1', 'UInt256'), 2]);
|
||||
SELECT toTypeName(arrayCumSumNonNegative([CAST('1', 'Int128'), -2]));
|
||||
SELECT toTypeName(arrayCumSumNonNegative([CAST('1', 'Int256'), -2]));
|
||||
SELECT toTypeName(arrayCumSumNonNegative([CAST('1', 'UInt128'), 2]));
|
||||
SELECT toTypeName(arrayCumSumNonNegative([CAST('1', 'UInt256'), 2]));
|
Loading…
Reference in New Issue
Block a user