From 140d57af4d92fb02705036f1c0bd287e3454e424 Mon Sep 17 00:00:00 2001 From: jacktengg <18241664+jacktengg@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:51:23 +0800 Subject: [PATCH] [fix](bitmap) fix coredump of bitmap_from_array caused by null array literal --- be/src/vec/functions/function_bitmap.cpp | 7 +++++++ .../bitmap_functions/test_bitmap_function.out | 6 ++++++ .../bitmap_functions/test_bitmap_function.groovy | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/be/src/vec/functions/function_bitmap.cpp b/be/src/vec/functions/function_bitmap.cpp index 988abdf11ef8a72..038741c3947d2b3 100644 --- a/be/src/vec/functions/function_bitmap.cpp +++ b/be/src/vec/functions/function_bitmap.cpp @@ -382,6 +382,9 @@ class FunctionBitmapAlwaysNull : public IFunction { if (check_column(nested_column)) { Impl::template vector(offset_column_data, nested_column, nested_null_map, res, null_map); + } else if (check_column(nested_column)) { + Impl::template vector(offset_column_data, nested_column, + nested_null_map, res, null_map); } else if (check_column(nested_column)) { Impl::template vector(offset_column_data, nested_column, nested_null_map, res, null_map); @@ -391,6 +394,10 @@ class FunctionBitmapAlwaysNull : public IFunction { } else if (check_column(nested_column)) { Impl::template vector(offset_column_data, nested_column, nested_null_map, res, null_map); + } else { + return Status::RuntimeError("Illegal column {} of argument of function {}", + block.get_by_position(arguments[0]).column->get_name(), + get_name()); } } else { return Status::RuntimeError("Illegal column {} of argument of function {}", diff --git a/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out b/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out index b009f1f1e8e1f39..d6ffc0d621aaa9a 100644 --- a/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out +++ b/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out @@ -702,3 +702,9 @@ true \N \N +-- !sql -- + + +-- !sql -- + + diff --git a/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy b/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy index 7847376c2aab793..709d2897212e2a6 100644 --- a/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy +++ b/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy @@ -1003,4 +1003,10 @@ suite("test_bitmap_function") { qt_sql_bitmap_remove_not_null8 """ select bitmap_to_string(bitmap_remove(id, 4294967296)) s from test_bitmap_remove_not_null order by s; """ qt_sql_bitmap_remove_not_null9 """ select bitmap_to_string(bitmap_remove(id, null)) s from test_bitmap_remove_not_null order by s; """ + // BITMAP_FROM_ARRAY + sql """ set experimental_enable_nereids_planner=false; """ + qt_sql """ select bitmap_to_string(BITMAP_FROM_ARRAY([]));""" + + sql """ set experimental_enable_nereids_planner=true; """ + qt_sql """ select bitmap_to_string(BITMAP_FROM_ARRAY([]));""" }