From c383a743f793cf471a12089acbc5655e498ff423 Mon Sep 17 00:00:00 2001 From: udiz Date: Wed, 13 Nov 2024 20:02:31 +0000 Subject: [PATCH] arrayWithConstant size estimation using single value size --- src/Functions/array/arrayWithConstant.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Functions/array/arrayWithConstant.cpp b/src/Functions/array/arrayWithConstant.cpp index 4cbc6404b9b..70d5080d1f9 100644 --- a/src/Functions/array/arrayWithConstant.cpp +++ b/src/Functions/array/arrayWithConstant.cpp @@ -62,16 +62,17 @@ public: for (size_t i = 0; i < num_rows; ++i) { auto array_size = col_num->getInt(i); + auto element_size = col_value->byteSizeAt(i); if (unlikely(array_size < 0)) throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} cannot be negative: while executing function {}", array_size, getName()); Int64 estimated_size = 0; - if (unlikely(common::mulOverflow(array_size, col_value->byteSize(), estimated_size))) - throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} with element size {} bytes is too large: while executing function {}", array_size, col_value->byteSize(), getName()); + if (unlikely(common::mulOverflow(array_size, element_size, estimated_size))) + throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} with element size {} bytes is too large: while executing function {}", array_size, element_size, getName()); if (unlikely(estimated_size > max_array_size_in_columns_bytes)) - throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} with element size {} bytes is too large: while executing function {}", array_size, col_value->byteSize(), getName()); + throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} with element size {} bytes is too large: while executing function {}", array_size, element_size, getName()); offset += array_size;