mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 09:10:48 +00:00
Fixed error in one of prev. revisions [#CLICKHOUSE-3150].
This commit is contained in:
parent
460d66c68d
commit
306070d2cc
@ -209,6 +209,8 @@ public:
|
||||
static FunctionPtr create(const Context &) { return std::make_shared<FunctionMathBinaryFloat64>(); }
|
||||
static_assert(Impl::rows_per_iteration > 0, "Impl must process at least one row per iteration");
|
||||
|
||||
bool useDefaultImplementationForConstants() const override { return true; }
|
||||
|
||||
private:
|
||||
String getName() const override { return name; }
|
||||
|
||||
@ -276,18 +278,6 @@ private:
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (const auto right_arg_typed = checkAndGetColumnConst<ColumnVector<RightType>>(right_arg))
|
||||
{
|
||||
const LeftType left_src[Impl::rows_per_iteration] { left_arg->template getValue<LeftType>() };
|
||||
const RightType right_src[Impl::rows_per_iteration] { right_arg_typed->template getValue<RightType>() };
|
||||
Float64 dst[Impl::rows_per_iteration];
|
||||
|
||||
Impl::execute(left_src, right_src, dst);
|
||||
|
||||
block.getByPosition(result).column = block.getByPosition(result).type->createConstColumn(left_arg->size(), dst[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -366,11 +356,36 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename LeftType, typename LeftColumnType>
|
||||
bool executeLeftImpl(Block & block, const ColumnNumbers & arguments, const size_t result,
|
||||
template <typename LeftType>
|
||||
bool executeLeft(Block & block, const ColumnNumbers & arguments, const size_t result,
|
||||
const IColumn * left_arg)
|
||||
{
|
||||
if (const auto left_arg_typed = typeid_cast<const LeftColumnType *>(left_arg))
|
||||
if (const auto left_arg_typed = checkAndGetColumn<ColumnVector<LeftType>>(left_arg))
|
||||
{
|
||||
const auto right_arg = block.getByPosition(arguments[1]).column.get();
|
||||
|
||||
if (executeRight<LeftType, UInt8>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, UInt16>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, UInt32>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, UInt64>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, Int8>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, Int16>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, Int32>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, Int64>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, Float32>(block, result, left_arg_typed, right_arg) ||
|
||||
executeRight<LeftType, Float64>(block, result, left_arg_typed, right_arg))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Exception{
|
||||
"Illegal column " + block.getByPosition(arguments[1]).column->getName() +
|
||||
" of second argument of function " + getName(),
|
||||
ErrorCodes::ILLEGAL_COLUMN};
|
||||
}
|
||||
}
|
||||
else if (const auto left_arg_typed = checkAndGetColumnConst<ColumnVector<LeftType>>(left_arg))
|
||||
{
|
||||
const auto right_arg = block.getByPosition(arguments[1]).column.get();
|
||||
|
||||
@ -399,17 +414,6 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename LeftType>
|
||||
bool executeLeft(Block & block, const ColumnNumbers & arguments, const size_t result,
|
||||
const IColumn * left_arg)
|
||||
{
|
||||
if (executeLeftImpl<LeftType, ColumnVector<LeftType>>(block, arguments, result, left_arg) ||
|
||||
executeLeftImpl<LeftType, ColumnConst>(block, arguments, result, left_arg))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void executeImpl(Block & block, const ColumnNumbers & arguments, const size_t result) override
|
||||
{
|
||||
const auto left_arg = block.getByPosition(arguments[0]).column.get();
|
||||
@ -427,8 +431,7 @@ private:
|
||||
{
|
||||
throw Exception{
|
||||
"Illegal column " + left_arg->getName() + " of argument of function " + getName(),
|
||||
ErrorCodes::ILLEGAL_COLUMN
|
||||
};
|
||||
ErrorCodes::ILLEGAL_COLUMN};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -179,9 +179,9 @@ enum ScaleMode
|
||||
};
|
||||
|
||||
#if !defined(_MM_FROUND_NINT)
|
||||
#define _MM_FROUND_NINT 0
|
||||
#define _MM_FROUND_FLOOR 1
|
||||
#define _MM_FROUND_CEIL 2
|
||||
#define _MM_FROUND_NINT 0
|
||||
#define _MM_FROUND_FLOOR 1
|
||||
#define _MM_FROUND_CEIL 2
|
||||
#endif
|
||||
|
||||
/** Implementing low-level rounding functions for integer values.
|
||||
@ -1127,12 +1127,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct NameRoundToExp2 { static constexpr auto name = "roundToExp2"; };
|
||||
struct NameRoundDuration { static constexpr auto name = "roundDuration"; };
|
||||
struct NameRoundAge { static constexpr auto name = "roundAge"; };
|
||||
struct NameRound { static constexpr auto name = "round"; };
|
||||
struct NameCeil { static constexpr auto name = "ceil"; };
|
||||
struct NameFloor { static constexpr auto name = "floor"; };
|
||||
struct NameRoundToExp2 { static constexpr auto name = "roundToExp2"; };
|
||||
struct NameRoundDuration { static constexpr auto name = "roundDuration"; };
|
||||
struct NameRoundAge { static constexpr auto name = "roundAge"; };
|
||||
struct NameRound { static constexpr auto name = "round"; };
|
||||
struct NameCeil { static constexpr auto name = "ceil"; };
|
||||
struct NameFloor { static constexpr auto name = "floor"; };
|
||||
|
||||
using FunctionRoundToExp2 = FunctionUnaryArithmetic<RoundToExp2Impl, NameRoundToExp2, false>;
|
||||
using FunctionRoundDuration = FunctionUnaryArithmetic<RoundDurationImpl, NameRoundDuration, false>;
|
||||
|
Loading…
Reference in New Issue
Block a user