From 3c75844a792a5e1d039c51f0135dad16a96bb1f6 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 11 Sep 2021 22:28:46 +0300 Subject: [PATCH] Fix SIGSEGV for arrayCompact() with consts arrayCompact() implements useDefaultImplementationForConstants() but it is a no-op for FunctionArrayMapped, fix this. CI report [1]: [1]: https://clickhouse-test-reports.s3.yandex.net/28890/baac2e561cfb05bc174f0bd25571e607d19c7463/fuzzer_asan/report.html#fail1 --- src/Functions/array/arrayCompact.cpp | 2 +- .../queries/0_stateless/01020_function_array_compact.reference | 2 ++ tests/queries/0_stateless/01020_function_array_compact.sql | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Functions/array/arrayCompact.cpp b/src/Functions/array/arrayCompact.cpp index e0f73207da8..4126f403516 100644 --- a/src/Functions/array/arrayCompact.cpp +++ b/src/Functions/array/arrayCompact.cpp @@ -16,7 +16,6 @@ namespace ErrorCodes struct ArrayCompactImpl { - static bool useDefaultImplementationForConstants() { return true; } static bool needBoolean() { return false; } static bool needExpression() { return false; } static bool needOneArray() { return false; } @@ -129,6 +128,7 @@ struct ArrayCompactImpl { ColumnPtr res; + mapped = mapped->convertToFullColumnIfConst(); if (!(executeType< UInt8 >(mapped, array, res) || executeType< UInt16>(mapped, array, res) || executeType< UInt32>(mapped, array, res) || diff --git a/tests/queries/0_stateless/01020_function_array_compact.reference b/tests/queries/0_stateless/01020_function_array_compact.reference index 6627a437251..4a6265b4f55 100644 --- a/tests/queries/0_stateless/01020_function_array_compact.reference +++ b/tests/queries/0_stateless/01020_function_array_compact.reference @@ -7,3 +7,5 @@ [1,2,1] [2,1] [1,2,3,4,5] +[0] +[0] diff --git a/tests/queries/0_stateless/01020_function_array_compact.sql b/tests/queries/0_stateless/01020_function_array_compact.sql index eea69dcb6da..d4aaa4d3fca 100644 --- a/tests/queries/0_stateless/01020_function_array_compact.sql +++ b/tests/queries/0_stateless/01020_function_array_compact.sql @@ -7,3 +7,5 @@ select arrayCompact([1,1,2]); select arrayCompact([1,2,1]); select arrayCompact([2,1,1]); select arrayCompact([1,2,2,3,3,3,4,4,4,4,5,5,5,5,5]); +SELECT arrayCompact(x->0, [NULL]); +SELECT toString(arrayCompact(x->0, [NULL]));