Some clean up

This commit is contained in:
Pavel Kruglov 2021-06-07 14:52:54 +03:00
parent 170f98572a
commit a95d45a157
6 changed files with 12 additions and 18 deletions

View File

@ -3,18 +3,15 @@
#include <Columns/ColumnNullable.h>
#include <Columns/ColumnNothing.h>
#include <Columns/ColumnsCommon.h>
#include <Columns/ColumnConst.h>
#include <algorithm>
#include <common/logger_useful.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int LOGICAL_ERROR;
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
}
template <typename T>
@ -234,8 +231,7 @@ int checkShirtCircuitArguments(const ColumnsWithTypeAndName & arguments)
int last_short_circuit_argument_index = -1;
for (size_t i = 0; i != arguments.size(); ++i)
{
const auto * column_func = checkAndGetColumn<ColumnFunction>(*arguments[i].column);
if (column_func && column_func->isShortCircuitArgument())
if (const auto * column_function = checkAndGetShortCircuitArgument(arguments[i].column))
last_short_circuit_argument_index = i;
}

View File

@ -491,7 +491,7 @@ class IColumn;
M(UInt64, offset, 0, "Offset on read rows from the most 'end' result for select query", 0) \
\
M(UInt64, function_range_max_elements_in_block, 500000000, "Maximum number of values generated by function 'range' per block of data (sum of array sizes for every row in a block, see also 'max_block_size' and 'min_insert_block_size_rows'). It is a safety threshold.", 0) \
M(Bool, use_short_circuit_function_evaluation, true, "", 0) \
M(Bool, use_short_circuit_function_evaluation, true, "Enable short-circuit function evaluation", 0) \
\
/** Experimental functions */ \
M(Bool, allow_experimental_funnel_functions, false, "Enable experimental functions for funnel analysis.", 0) \

View File

@ -598,8 +598,8 @@ class FunctionBinaryArithmetic : public IFunction
static FunctionOverloadResolverPtr
getFunctionForIntervalArithmetic(const DataTypePtr & type0, const DataTypePtr & type1, ContextPtr context)
{
bool first_is_date_or_datetime = isDate(type0) || isDateTime(type0) || isDateTime64(type0);
bool second_is_date_or_datetime = isDate(type1) || isDateTime(type1) || isDateTime64(type1);
bool first_is_date_or_datetime = isDateOrDateTime(type0);
bool second_is_date_or_datetime = isDateOrDateTime(type1);
/// Exactly one argument must be Date or DateTime
if (first_is_date_or_datetime == second_is_date_or_datetime)
@ -774,7 +774,7 @@ class FunctionBinaryArithmetic : public IFunction
ColumnsWithTypeAndName new_arguments = arguments;
/// Interval argument must be second.
if (isDate(arguments[1].type) || isDateTime(arguments[1].type) || isDateTime64(arguments[1].type))
if (WhichDataType(arguments[1].type).isDateOrDateTime())
std::swap(new_arguments[0], new_arguments[1]);
/// Change interval argument type to its representation
@ -957,7 +957,6 @@ public:
bool isSuitableForShortCircuitArgumentsExecution(ColumnsWithTypeAndName & arguments) const override
{
return (IsOperation<Op>::div_int || IsOperation<Op>::modulo) && !isColumnConst(*arguments[1].column);
}
@ -995,7 +994,7 @@ public:
new_arguments[i].type = arguments[i];
/// Interval argument must be second.
if (isDate(new_arguments[1].type) || isDateTime(new_arguments[1].type) || isDateTime64(new_arguments[1].type))
if (WhichDataType(new_arguments[1].type).isDateOrDateTime())
std::swap(new_arguments[0], new_arguments[1]);
/// Change interval argument to its representation

View File

@ -31,7 +31,6 @@ void FunctionFactory::registerFunction(const
Value creator,
CaseSensitiveness case_sensitiveness)
{
if (!functions.emplace(name, creator).second)
throw Exception("FunctionFactory: the function name '" + name + "' is not unique",
ErrorCodes::LOGICAL_ERROR);

View File

@ -21,7 +21,7 @@ namespace ErrorCodes
}
template <typename Impl, typename Name, typename ResultType, bool is_suitable_for_short_circuit_arguments_execution = false>
template <typename Impl, typename Name, typename ResultType, bool is_suitable_for_short_circuit_arguments_execution = true>
class FunctionStringOrArrayToT : public IFunction
{
public:
@ -43,7 +43,7 @@ public:
bool isSuitableForShortCircuitArgumentsExecution(ColumnsWithTypeAndName & /*arguments*/) const override
{
return true;
return is_suitable_for_short_circuit_arguments_execution;
}
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override

View File

@ -2720,7 +2720,7 @@ private:
if (!from_type)
{
throw Exception(ErrorCodes::TYPE_MISMATCH,
"CAST AS Array can only be perforamed between same-dimensional Array or String types");
"CAST AS Array can only be performed between same-dimensional Array or String types");
}
DataTypePtr from_nested_type = from_type->getNestedType();
@ -2730,7 +2730,7 @@ private:
if (from_type->getNumberOfDimensions() != to_type.getNumberOfDimensions() && !from_empty_array)
throw Exception(ErrorCodes::TYPE_MISMATCH,
"CAST AS Array can only be perforamed between same-dimensional array types");
"CAST AS Array can only be performed between same-dimensional array types");
const DataTypePtr & to_nested_type = to_type.getNestedType();