diff --git a/be/src/vec/columns/column_const.cpp b/be/src/vec/columns/column_const.cpp index 4720b4cd02..d2cb9ef7e7 100644 --- a/be/src/vec/columns/column_const.cpp +++ b/be/src/vec/columns/column_const.cpp @@ -36,7 +36,8 @@ ColumnConst::ColumnConst(const ColumnPtr& data_, size_t s_) : data(data_), s(s_) if (data->size() != 1) { LOG(FATAL) << fmt::format( - "Incorrect size of nested column in constructor of ColumnConst: {}, must be 1."); + "Incorrect size of nested column in constructor of ColumnConst: {}, must be 1.", + data->size()); } } diff --git a/be/src/vec/functions/function_bitmap.cpp b/be/src/vec/functions/function_bitmap.cpp index 247dcab19b..4350d3b256 100644 --- a/be/src/vec/functions/function_bitmap.cpp +++ b/be/src/vec/functions/function_bitmap.cpp @@ -183,11 +183,17 @@ struct BitmapFromString { static constexpr auto name = "bitmap_from_string"; static Status vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets, - std::vector& res, NullMap& null_map) { - auto size = offsets.size(); - res.reserve(size); + std::vector& res, NullMap& null_map, + size_t input_rows_count) { + res.reserve(input_rows_count); std::vector bits; - for (size_t i = 0; i < size; ++i) { + if (offsets.size() == 0 && input_rows_count == 1) { + // For NULL constant + res.emplace_back(); + null_map[0] = 1; + return Status::OK(); + } + for (size_t i = 0; i < input_rows_count; ++i) { const char* raw_str = reinterpret_cast(&data[offsets[i - 1]]); int64_t str_size = offsets[i] - offsets[i - 1]; @@ -272,7 +278,7 @@ public: const auto& str_column = static_cast(*argument_column); const ColumnString::Chars& data = str_column.get_chars(); const ColumnString::Offsets& offsets = str_column.get_offsets(); - Impl::vector(data, offsets, res, null_map); + Impl::vector(data, offsets, res, null_map, input_rows_count); } else if constexpr (std::is_same_v) { auto argument_type = remove_nullable( assert_cast(*block.get_by_position(arguments[0]).type) diff --git a/regression-test/data/datatype_p0/bitmap/test_bitmap_const.out b/regression-test/data/datatype_p0/bitmap/test_bitmap_const.out new file mode 100644 index 0000000000..2871306509 --- /dev/null +++ b/regression-test/data/datatype_p0/bitmap/test_bitmap_const.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +\N + diff --git a/regression-test/suites/datatype_p0/bitmap/test_bitmap_const.groovy b/regression-test/suites/datatype_p0/bitmap/test_bitmap_const.groovy new file mode 100644 index 0000000000..e824ed631b --- /dev/null +++ b/regression-test/suites/datatype_p0/bitmap/test_bitmap_const.groovy @@ -0,0 +1,22 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_bitmap_const") { + qt_select "select bitmap_from_string( cast(null as TEXT));" +} + +