mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
FIXUP: FunctionArrayMapped - Simpler arg passing for check/exec
This commit is contained in:
parent
c2f5331a2d
commit
cae064822c
@ -194,8 +194,7 @@ public:
|
||||
arguments[num_fixed_params].type->getName());
|
||||
|
||||
if constexpr (num_fixed_params)
|
||||
Impl::checkArguments(
|
||||
std::span<const ColumnWithTypeAndName, num_fixed_params>(std::begin(arguments), num_fixed_params), getName());
|
||||
Impl::checkArguments(getName(), arguments.data());
|
||||
|
||||
DataTypePtr nested_type = data_type->getNestedType();
|
||||
|
||||
@ -229,8 +228,7 @@ public:
|
||||
arguments[0].type->getName());
|
||||
|
||||
if constexpr (num_fixed_params)
|
||||
Impl::checkArguments(
|
||||
std::span<const ColumnWithTypeAndName, num_fixed_params>(std::begin(arguments) + 1, num_fixed_params), getName());
|
||||
Impl::checkArguments(getName(), arguments.data() + 1);
|
||||
|
||||
/// The types of the remaining arguments are already checked in getLambdaArgumentTypes.
|
||||
|
||||
@ -294,7 +292,7 @@ public:
|
||||
return Impl::execute(
|
||||
*column_array,
|
||||
column_array->getNestedColumn().getDataPtr(),
|
||||
std::span<const ColumnWithTypeAndName, num_fixed_params>(std::begin(arguments), num_fixed_params));
|
||||
arguments.data());
|
||||
else
|
||||
return Impl::execute(*column_array, column_array->getNestedColumn().getDataPtr());
|
||||
}
|
||||
@ -304,7 +302,7 @@ public:
|
||||
return Impl::execute(
|
||||
*column_array,
|
||||
column_array->getDataPtr(),
|
||||
std::span<const ColumnWithTypeAndName, num_fixed_params>(std::begin(arguments), num_fixed_params));
|
||||
arguments.data());
|
||||
else
|
||||
return Impl::execute(*column_array, column_array->getDataPtr());
|
||||
}
|
||||
@ -439,7 +437,7 @@ public:
|
||||
return Impl::execute(
|
||||
*column_first_array,
|
||||
lambda_result.column,
|
||||
std::span<const ColumnWithTypeAndName, num_fixed_params>(std::begin(arguments) + 1, num_fixed_params));
|
||||
arguments.data() + 1);
|
||||
else
|
||||
return Impl::execute(*column_first_array, lambda_result.column);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
/** Sort arrays, by values of its elements, or by values of corresponding elements of calculated expression (known as "schwartzsort").
|
||||
@ -45,31 +46,38 @@ struct ArraySortImpl
|
||||
}
|
||||
};
|
||||
|
||||
static void checkArguments(std::span<const ColumnWithTypeAndName, num_fixed_params> arguments, const String & name)
|
||||
static void checkArguments(const String & name, const ColumnWithTypeAndName * fixed_arguments)
|
||||
requires(num_fixed_params)
|
||||
{
|
||||
if (arguments.size() != 1)
|
||||
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} needs limit argument", name);
|
||||
|
||||
WhichDataType which(arguments[0].type.get());
|
||||
if (!fixed_arguments)
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Expected fixed arguments to get the limit for partial array sort"
|
||||
);
|
||||
WhichDataType which(fixed_arguments[0].type.get());
|
||||
if (!which.isUInt() && !which.isInt())
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Illegal type {} of limit argument of function {} (must be UInt or Int)",
|
||||
arguments[0].type->getName(),
|
||||
fixed_arguments[0].type->getName(),
|
||||
name);
|
||||
}
|
||||
|
||||
static ColumnPtr execute(
|
||||
const ColumnArray & array,
|
||||
ColumnPtr mapped,
|
||||
std::span<const ColumnWithTypeAndName, num_fixed_params> arguments [[maybe_unused]] = {})
|
||||
const ColumnWithTypeAndName * fixed_arguments [[maybe_unused]] = nullptr)
|
||||
{
|
||||
[[maybe_unused]] const auto limit = [&]() -> size_t
|
||||
{
|
||||
if constexpr (is_partial)
|
||||
{
|
||||
return arguments[0].column.get()->getUInt(0);
|
||||
if (!fixed_arguments)
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Expected fixed arguments to get the limit for partial array sort"
|
||||
);
|
||||
return fixed_arguments[0].column.get()->getUInt(0);
|
||||
}
|
||||
return 0;
|
||||
}();
|
||||
|
Loading…
Reference in New Issue
Block a user