mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fixed error with Arrays inside Nested data type; added a test #2066
This commit is contained in:
parent
499b67642f
commit
958a3d7ee7
@ -70,8 +70,13 @@ size_t IDataType::getSizeOfValueInMemory() const
|
|||||||
|
|
||||||
String IDataType::getFileNameForStream(const String & column_name, const IDataType::SubstreamPath & path)
|
String IDataType::getFileNameForStream(const String & column_name, const IDataType::SubstreamPath & path)
|
||||||
{
|
{
|
||||||
|
/// Sizes of arrays (elements of Nested type) are shared (all reside in single file).
|
||||||
String nested_table_name = Nested::extractTableName(column_name);
|
String nested_table_name = Nested::extractTableName(column_name);
|
||||||
bool is_sizes_of_nested_type = !path.empty() && path.back().type == IDataType::Substream::ArraySizes
|
|
||||||
|
bool is_sizes_of_nested_type =
|
||||||
|
path.size() == 1 /// Nested structure may have arrays as nested elements (so effectively we have multidimentional arrays).
|
||||||
|
/// Sizes of arrays are shared only at first level.
|
||||||
|
&& path[0].type == IDataType::Substream::ArraySizes
|
||||||
&& nested_table_name != column_name;
|
&& nested_table_name != column_name;
|
||||||
|
|
||||||
size_t array_level = 0;
|
size_t array_level = 0;
|
||||||
|
@ -365,7 +365,7 @@ void MergeTreeReader::readData(
|
|||||||
IDataType::InputStreamGetter stream_getter = [&] (const IDataType::SubstreamPath & path) -> ReadBuffer *
|
IDataType::InputStreamGetter stream_getter = [&] (const IDataType::SubstreamPath & path) -> ReadBuffer *
|
||||||
{
|
{
|
||||||
/// If offsets for arrays have already been read.
|
/// If offsets for arrays have already been read.
|
||||||
if (!with_offsets && !path.empty() && path.back().type == IDataType::Substream::ArraySizes)
|
if (!with_offsets && path.size() == 1 && path[0].type == IDataType::Substream::ArraySizes)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
String stream_name = IDataType::getFileNameForStream(name, path);
|
String stream_name = IDataType::getFileNameForStream(name, path);
|
||||||
|
@ -150,6 +150,7 @@ private:
|
|||||||
class MergedColumnOnlyOutputStream final : public IMergedBlockOutputStream
|
class MergedColumnOnlyOutputStream final : public IMergedBlockOutputStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// skip_offsets: used when ALTERing columns if we know that array offsets are not altered.
|
||||||
MergedColumnOnlyOutputStream(
|
MergedColumnOnlyOutputStream(
|
||||||
MergeTreeData & storage_, const Block & header_, String part_path_, bool sync_, CompressionSettings compression_settings, bool skip_offsets_);
|
MergeTreeData & storage_, const Block & header_, String part_path_, bool sync_, CompressionSettings compression_settings, bool skip_offsets_);
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
['Hello','World'] [['a'],['b','c']] [['PU','US'],['OTHER']]
|
||||||
|
['Hello','World'] [['a'],['b','c']] [['PU','US'],['OTHER']]
|
||||||
|
['Hello','World'] [['a'],['b','c']] [['PU','US'],['OTHER']]
|
||||||
|
['Hello','World'] [['a'],['b','c']] [['PU','US'],['OTHER']]
|
||||||
|
['Hello','World'] [['a'],['b','c']] [['PU','US'],['OTHER']]
|
83
dbms/tests/queries/0_stateless/00625_arrays_in_nested.sql
Normal file
83
dbms/tests/queries/0_stateless/00625_arrays_in_nested.sql
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
USE test;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS nested;
|
||||||
|
CREATE TABLE nested
|
||||||
|
(
|
||||||
|
column Nested
|
||||||
|
(
|
||||||
|
name String,
|
||||||
|
names Array(String),
|
||||||
|
types Array(Enum8('PU' = 1, 'US' = 2, 'OTHER' = 3))
|
||||||
|
)
|
||||||
|
) ENGINE = MergeTree ORDER BY tuple();
|
||||||
|
|
||||||
|
INSERT INTO nested VALUES (['Hello', 'World'], [['a'], ['b', 'c']], [['PU', 'US'], ['OTHER']]);
|
||||||
|
|
||||||
|
SELECT * FROM nested;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS nested;
|
||||||
|
CREATE TABLE nested
|
||||||
|
(
|
||||||
|
column Nested
|
||||||
|
(
|
||||||
|
name String,
|
||||||
|
names Array(String),
|
||||||
|
types Array(Enum8('PU' = 1, 'US' = 2, 'OTHER' = 3))
|
||||||
|
)
|
||||||
|
) ENGINE = Log;
|
||||||
|
|
||||||
|
INSERT INTO nested VALUES (['Hello', 'World'], [['a'], ['b', 'c']], [['PU', 'US'], ['OTHER']]);
|
||||||
|
|
||||||
|
SELECT * FROM nested;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS nested;
|
||||||
|
CREATE TABLE nested
|
||||||
|
(
|
||||||
|
column Nested
|
||||||
|
(
|
||||||
|
name String,
|
||||||
|
names Array(String),
|
||||||
|
types Array(Enum8('PU' = 1, 'US' = 2, 'OTHER' = 3))
|
||||||
|
)
|
||||||
|
) ENGINE = TinyLog;
|
||||||
|
|
||||||
|
INSERT INTO nested VALUES (['Hello', 'World'], [['a'], ['b', 'c']], [['PU', 'US'], ['OTHER']]);
|
||||||
|
|
||||||
|
SELECT * FROM nested;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS nested;
|
||||||
|
CREATE TABLE nested
|
||||||
|
(
|
||||||
|
column Nested
|
||||||
|
(
|
||||||
|
name String,
|
||||||
|
names Array(String),
|
||||||
|
types Array(Enum8('PU' = 1, 'US' = 2, 'OTHER' = 3))
|
||||||
|
)
|
||||||
|
) ENGINE = StripeLog;
|
||||||
|
|
||||||
|
INSERT INTO nested VALUES (['Hello', 'World'], [['a'], ['b', 'c']], [['PU', 'US'], ['OTHER']]);
|
||||||
|
|
||||||
|
SELECT * FROM nested;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS nested;
|
||||||
|
CREATE TABLE nested
|
||||||
|
(
|
||||||
|
column Nested
|
||||||
|
(
|
||||||
|
name String,
|
||||||
|
names Array(String),
|
||||||
|
types Array(Enum8('PU' = 1, 'US' = 2, 'OTHER' = 3))
|
||||||
|
)
|
||||||
|
) ENGINE = Memory;
|
||||||
|
|
||||||
|
INSERT INTO nested VALUES (['Hello', 'World'], [['a'], ['b', 'c']], [['PU', 'US'], ['OTHER']]);
|
||||||
|
|
||||||
|
SELECT * FROM nested;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE nested;
|
Loading…
Reference in New Issue
Block a user