mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #71894 from udiz/fix-arrayWithConstant-size-estimation
Fix: arrayWithConstant size estimation using row's element size
This commit is contained in:
commit
40c7d5fd1a
@ -62,16 +62,17 @@ public:
|
|||||||
for (size_t i = 0; i < num_rows; ++i)
|
for (size_t i = 0; i < num_rows; ++i)
|
||||||
{
|
{
|
||||||
auto array_size = col_num->getInt(i);
|
auto array_size = col_num->getInt(i);
|
||||||
|
auto element_size = col_value->byteSizeAt(i);
|
||||||
|
|
||||||
if (unlikely(array_size < 0))
|
if (unlikely(array_size < 0))
|
||||||
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} cannot be negative: while executing function {}", array_size, getName());
|
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Array size {} cannot be negative: while executing function {}", array_size, getName());
|
||||||
|
|
||||||
Int64 estimated_size = 0;
|
Int64 estimated_size = 0;
|
||||||
if (unlikely(common::mulOverflow(array_size, col_value->byteSize(), estimated_size)))
|
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, 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());
|
||||||
|
|
||||||
if (unlikely(estimated_size > max_array_size_in_columns_bytes))
|
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;
|
offset += array_size;
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
SELECT arrayWithConstant(96142475, ['qMUF']); -- { serverError TOO_LARGE_ARRAY_SIZE }
|
SELECT arrayWithConstant(96142475, ['qMUF']); -- { serverError TOO_LARGE_ARRAY_SIZE }
|
||||||
SELECT arrayWithConstant(100000000, materialize([[[[[[[[[['Hello, world!']]]]]]]]]])); -- { serverError TOO_LARGE_ARRAY_SIZE }
|
SELECT arrayWithConstant(100000000, materialize([[[[[[[[[['Hello, world!']]]]]]]]]])); -- { serverError TOO_LARGE_ARRAY_SIZE }
|
||||||
SELECT length(arrayWithConstant(10000000, materialize([[[[[[[[[['Hello world']]]]]]]]]])));
|
SELECT length(arrayWithConstant(10000000, materialize([[[[[[[[[['Hello world']]]]]]]]]])));
|
||||||
|
|
||||||
|
CREATE TEMPORARY TABLE args (value Array(Int)) ENGINE=Memory AS SELECT [1, 1, 1, 1] as value FROM numbers(1, 100);
|
||||||
|
SELECT length(arrayWithConstant(1000000, value)) FROM args FORMAT NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user