mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Fix possible out of bounds error while reading LowCardinality(Nullable) in Arrow format
This commit is contained in:
parent
8bdb1c3453
commit
deda940d87
@ -384,9 +384,10 @@ static ColumnWithTypeAndName readColumnWithIndexesDataImpl(std::shared_ptr<arrow
|
||||
const auto * data = reinterpret_cast<const NumericType *>(buffer->data());
|
||||
|
||||
/// Check that indexes are correct (protection against corrupted files)
|
||||
/// Note that on null values index can be arbitrary value.
|
||||
for (int64_t i = 0; i != chunk->length(); ++i)
|
||||
{
|
||||
if (data[i] < 0 || data[i] >= dict_size)
|
||||
if (!chunk->IsNull(i) && (data[i] < 0 || data[i] >= dict_size))
|
||||
throw Exception(ErrorCodes::INCORRECT_DATA,
|
||||
"Index {} in Dictionary column is out of bounds, dictionary size is {}",
|
||||
Int64(data[i]), UInt64(dict_size));
|
||||
|
@ -0,0 +1,2 @@
|
||||
0
|
||||
\N
|
14
tests/queries/0_stateless/02563_arrow_low_cardinality_bug.sh
Executable file
14
tests/queries/0_stateless/02563_arrow_low_cardinality_bug.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "drop table if exists test"
|
||||
$CLICKHOUSE_CLIENT -q "create table test (z LowCardinality(Nullable(String))) engine=Memory";
|
||||
$CLICKHOUSE_CLIENT -q "select CAST(number % 2 ? NULL : toString(number), 'LowCardinality(Nullable(String))') as z from numbers(2) format Arrow settings output_format_arrow_low_cardinality_as_dictionary=1" | $CLICKHOUSE_CLIENT -q "insert into test format Arrow"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "select * from test"
|
||||
$CLICKHOUSE_CLIENT -q "drop table test"
|
||||
|
Loading…
Reference in New Issue
Block a user