From 4290b1fe2cfe6eace74c08601db884f0c1738bf8 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 15 Mar 2024 11:32:21 +0100 Subject: [PATCH] Garbage --- src/Functions/FunctionsConversion.cpp | 49 +++++++-------------------- src/Functions/castOrDefault.cpp | 2 +- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/src/Functions/FunctionsConversion.cpp b/src/Functions/FunctionsConversion.cpp index 42056067f00..f69d3e9146b 100644 --- a/src/Functions/FunctionsConversion.cpp +++ b/src/Functions/FunctionsConversion.cpp @@ -1980,13 +1980,6 @@ public: static constexpr bool to_datetime64 = std::is_same_v; - static constexpr bool to_string_or_fixed_string = std::is_same_v || - std::is_same_v; - - static constexpr bool to_date_or_datetime = std::is_same_v || - std::is_same_v || - std::is_same_v; - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } static FunctionPtr create() { return std::make_shared(); } @@ -2003,8 +1996,7 @@ public: bool isInjective(const ColumnsWithTypeAndName &) const override { return std::is_same_v; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & arguments) const override { - /// TODO: We can make more optimizations here. - return !(to_date_or_datetime && isNumber(*arguments[0].type)); + return !(IsDataTypeDateOrDateTime && isNumber(*arguments[0].type)); } using DefaultReturnTypeGetter = std::function; @@ -2327,7 +2319,7 @@ private: } bool done = false; - if constexpr (to_string_or_fixed_string) + if constexpr (std::is_same_v || std::is_same_v) { done = callOnIndexAndDataType(from_type->getTypeId(), call, ConvertDefaultBehaviorTag{}); } @@ -3155,7 +3147,6 @@ public: } private: - const char * cast_name; MonotonicityForRange monotonicity_for_range; @@ -4623,26 +4614,12 @@ arguments, result_type, input_rows_count); \ using Types = std::decay_t; using ToDataType = typename Types::LeftType; - if constexpr ( - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v) + if constexpr (is_any_of) { ret = createWrapper(from_type, checkAndGetDataType(to_type.get()), requested_result_is_nullable); return true; @@ -4662,12 +4639,10 @@ arguments, result_type, input_rows_count); \ ret = createEnumWrapper(from_type, checkAndGetDataType(to_type.get())); return true; } - if constexpr ( - std::is_same_v> || - std::is_same_v> || - std::is_same_v> || - std::is_same_v> || - std::is_same_v) + if constexpr (is_any_of, DataTypeDecimal, + DataTypeDecimal, DataTypeDecimal, + DataTypeDateTime64>) { ret = createDecimalWrapper(from_type, checkAndGetDataType(to_type.get()), requested_result_is_nullable); return true; diff --git a/src/Functions/castOrDefault.cpp b/src/Functions/castOrDefault.cpp index 18bdea28029..57cb03e0349 100644 --- a/src/Functions/castOrDefault.cpp +++ b/src/Functions/castOrDefault.cpp @@ -303,7 +303,7 @@ private: }; ColumnsWithTypeAndName arguments_with_cast_type; - arguments_with_cast_type.reserve(arguments.size()); + arguments_with_cast_type.reserve(arguments.size() + 1); arguments_with_cast_type.emplace_back(arguments[0]); arguments_with_cast_type.emplace_back(second_argument);