diff --git a/src/Columns/ColumnFunction.cpp b/src/Columns/ColumnFunction.cpp index ba219cafc29..150caed0d3e 100644 --- a/src/Columns/ColumnFunction.cpp +++ b/src/Columns/ColumnFunction.cpp @@ -194,6 +194,8 @@ void ColumnFunction::appendArgument(const ColumnWithTypeAndName & column) ColumnWithTypeAndName ColumnFunction::reduce(bool reduce_arguments) const { +// LOG_DEBUG(&Poco::Logger::get("ColumnFunction"), "Reduce function: {}", function->getName()); + auto args = function->getArgumentTypes().size(); auto captured = captured_columns.size(); @@ -207,7 +209,7 @@ ColumnWithTypeAndName ColumnFunction::reduce(bool reduce_arguments) const columns.reserve(captured_columns.size()); for (const auto & col : captured_columns) { - LOG_DEBUG(&Poco::Logger::get("ColumnFunction"), "Arg type: {}", col.type->getName()); +// LOG_DEBUG(&Poco::Logger::get("ColumnFunction"), "Arg type: {}", col.type->getName()); if (const auto * column_function = typeid_cast(col.column.get())) columns.push_back(column_function->reduce(true)); diff --git a/src/Columns/MaskOperations.cpp b/src/Columns/MaskOperations.cpp index 44db69809ed..99ec5e7c7f1 100644 --- a/src/Columns/MaskOperations.cpp +++ b/src/Columns/MaskOperations.cpp @@ -126,7 +126,7 @@ void disjunctionMasks(PaddedPODArray & mask1, const PaddedPODArray binaryMasksOperationImpl(mask1, mask2, [](const auto & lhs, const auto & rhs){ return lhs | rhs; }); } -void maskedExecute(ColumnWithTypeAndName & column, const PaddedPODArray & mask, bool reverse, Field * default_value) +void maskedExecute(ColumnWithTypeAndName & column, const PaddedPODArray & mask, Field * default_value, bool reverse) { const auto * column_function = checkAndGetColumn(*column.column); if (!column_function) diff --git a/src/Columns/MaskOperations.h b/src/Columns/MaskOperations.h index 7b930071c48..14fa46ae8cf 100644 --- a/src/Columns/MaskOperations.h +++ b/src/Columns/MaskOperations.h @@ -13,7 +13,7 @@ void conjunctionMasks(PaddedPODArray & mask1, const PaddedPODArray void disjunctionMasks(PaddedPODArray & mask1, const PaddedPODArray & mask2); -void maskedExecute(ColumnWithTypeAndName & column, const PaddedPODArray & mask, bool reverse = false, Field * default_value = nullptr); +void maskedExecute(ColumnWithTypeAndName & column, const PaddedPODArray & mask, Field * default_value = nullptr, bool reverse = false); void executeColumnIfNeeded(ColumnWithTypeAndName & column); diff --git a/src/Functions/FunctionsLogical.cpp b/src/Functions/FunctionsLogical.cpp index 3680b1627e5..d0b95679478 100644 --- a/src/Functions/FunctionsLogical.cpp +++ b/src/Functions/FunctionsLogical.cpp @@ -525,7 +525,7 @@ void FunctionAnyArityLogical::executeShortCircuitArguments(ColumnsWi for (size_t i = 1; i < arguments.size(); ++i) { if (isColumnFunction(*arguments[i].column)) - maskedExecute(arguments[i], mask, false, &default_value); + maskedExecute(arguments[i], mask, &default_value, false); getMaskFromColumn(arguments[i].column, mask, reverse, nullptr, null_value); } } diff --git a/src/Functions/if.cpp b/src/Functions/if.cpp index 75550678a06..a51e8337383 100644 --- a/src/Functions/if.cpp +++ b/src/Functions/if.cpp @@ -928,7 +928,7 @@ public: IColumn::Filter mask; getMaskFromColumn(arguments[0].column, mask); maskedExecute(arguments[1], mask); - maskedExecute(arguments[2], mask, /*reverse=*/true); + maskedExecute(arguments[2], mask, nullptr, /*reverse=*/true); } } diff --git a/src/Functions/multiIf.cpp b/src/Functions/multiIf.cpp index 53010aa2a4d..958ad434b44 100644 --- a/src/Functions/multiIf.cpp +++ b/src/Functions/multiIf.cpp @@ -114,7 +114,7 @@ public: IColumn::Filter current_mask; IColumn::Filter mask_disjunctions = IColumn::Filter(arguments[0].column->size(), 0); - Field default_value = 0; + auto default_value = std::make_unique(1); size_t i = 1; while (i < arguments.size()) { @@ -124,9 +124,11 @@ public: maskedExecute(arguments[i], current_mask); ++i; + if (i == arguments.size() - 1) + default_value = nullptr; if (isColumnFunction(*arguments[i].column)) - maskedExecute(arguments[i], mask_disjunctions, true, &default_value); + maskedExecute(arguments[i], mask_disjunctions, default_value.get(), true); ++i; }