From 68034103bbcd06ffd558279616fffc993b02e14b Mon Sep 17 00:00:00 2001 From: chertus Date: Thu, 27 Jun 2019 15:49:08 +0300 Subject: [PATCH] fix arrayIndex for new columns's isNullable --- dbms/src/Functions/array/arrayIndex.h | 39 ++++++++++++--------------- dbms/src/Interpreters/Join.cpp | 2 +- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/dbms/src/Functions/array/arrayIndex.h b/dbms/src/Functions/array/arrayIndex.h index 97df807a270..61c51a79e6c 100644 --- a/dbms/src/Functions/array/arrayIndex.h +++ b/dbms/src/Functions/array/arrayIndex.h @@ -907,22 +907,21 @@ public: /// (they are vectors of Fields, which may represent the NULL value), /// they do not require any preprocessing - /// Check if the 1st function argument is a non-constant array of nullable - /// values. - bool is_nullable; - const ColumnArray * col_array = checkAndGetColumn(block.getByPosition(arguments[0]).column.get()); - if (col_array) - is_nullable = col_array->getData().isColumnNullable(); - else - is_nullable = false; - /// Check nullability of the 2nd function argument. - bool is_arg_nullable = block.getByPosition(arguments[1]).column->isColumnNullable(); + const ColumnNullable * nullable = nullptr; + if (col_array && !col_array->getData().isColumnConst()) + nullable = getNullableColumn(col_array->getData()); - if (!is_nullable && !is_arg_nullable) + auto & arg_column = block.getByPosition(arguments[1]).column; + + const ColumnNullable * arg_nullable = nullptr; + if (!arg_column->isColumnConst()) + arg_nullable = getNullableColumn(*arg_column); + + if (!nullable && !arg_nullable) { - /// Simple case: no nullable value is passed. + /// Simple case: no or constant nullable values passeded. perform(block, arguments, result); } else @@ -955,10 +954,9 @@ public: } }; - if (is_nullable) + if (nullable) { - const auto & nullable_col = static_cast(col_array->getData()); - const auto & nested_col = nullable_col.getNestedColumnPtr(); + const auto & nested_col = nullable->getNestedColumnPtr(); auto & data = source_block.getByPosition(0); data.column = ColumnArray::create(nested_col, col_array->getOffsetsPtr()); @@ -967,7 +965,7 @@ public: *static_cast(*block.getByPosition(arguments[0]).type).getNestedType()).getNestedType()); auto & null_map = source_block.getByPosition(2); - null_map.column = nullable_col.getNullMapColumnPtr(); + null_map.column = nullable->getNullMapColumnPtr(); null_map.type = std::make_shared(); } else @@ -976,17 +974,14 @@ public: data = block.getByPosition(arguments[0]); } - if (is_arg_nullable) + if (arg_nullable) { - const auto & col = block.getByPosition(arguments[1]).column; - const auto & nullable_col = static_cast(*col); - auto & arg = source_block.getByPosition(1); - arg.column = nullable_col.getNestedColumnPtr(); + arg.column = arg_nullable->getNestedColumnPtr(); arg.type = static_cast(*block.getByPosition(arguments[1]).type).getNestedType(); auto & null_map = source_block.getByPosition(3); - null_map.column = nullable_col.getNullMapColumnPtr(); + null_map.column = arg_nullable->getNullMapColumnPtr(); null_map.type = std::make_shared(); } else diff --git a/dbms/src/Interpreters/Join.cpp b/dbms/src/Interpreters/Join.cpp index be6b69f005f..8c5bf6079cb 100644 --- a/dbms/src/Interpreters/Join.cpp +++ b/dbms/src/Interpreters/Join.cpp @@ -73,7 +73,7 @@ static ColumnWithTypeAndName correctNullability(ColumnWithTypeAndName && column, if (negative_null_map.size()) { MutableColumnPtr mutable_column = (*std::move(column.column)).mutate(); - static_cast(*mutable_column).applyNegatedNullMap(negative_null_map); + getNullableColumnRef(*mutable_column).applyNegatedNullMap(negative_null_map); column.column = std::move(mutable_column); } }