fix alters of nested

This commit is contained in:
Anton Popov 2020-12-18 15:27:15 +03:00
parent a42b00c9aa
commit 31e6956ac8
5 changed files with 13 additions and 16 deletions

View File

@ -48,19 +48,6 @@ String IDataType::Substream::toString() const
__builtin_unreachable();
}
size_t IDataType::SubstreamPath::getHash() const
{
SipHash hash;
for (const auto & elem : *this)
{
hash.update(elem.type);
hash.update(elem.tuple_element_name);
hash.update(elem.escape_tuple_delimiter);
}
return hash.get64();
}
String IDataType::SubstreamPath::toString() const
{
WriteBufferFromOwnString wb;

View File

@ -112,7 +112,6 @@ public:
struct SubstreamPath : public std::vector<Substream>
{
UInt64 getHash() const;
String toString() const;
};

View File

@ -42,7 +42,14 @@ IMergeTreeReader::IMergeTreeReader(
, all_mark_ranges(all_mark_ranges_)
, alter_conversions(storage.getAlterConversionsForPart(data_part))
{
for (const NameAndTypePair & column_from_part : data_part->getColumns())
auto part_columns = data_part->getColumns();
if (settings.convert_nested_to_subcolumns)
{
columns = Nested::convertToSubcolumns(columns);
part_columns = Nested::collect(part_columns);
}
for (const NameAndTypePair & column_from_part : part_columns)
columns_from_part[column_from_part.name] = column_from_part.type;
}

View File

@ -48,9 +48,12 @@ IMergeTreeDataPart::MergeTreeReaderPtr MergeTreeDataPartWide::getReader(
const ValueSizeMap & avg_value_size_hints,
const ReadBufferFromFileBase::ProfileCallback & profile_callback) const
{
auto new_settings = reader_settings;
new_settings.convert_nested_to_subcolumns = true;
auto ptr = std::static_pointer_cast<const MergeTreeDataPartWide>(shared_from_this());
return std::make_unique<MergeTreeReaderWide>(
ptr, Nested::convertToSubcolumns(columns_to_read), metadata_snapshot, uncompressed_cache,
ptr, columns_to_read, metadata_snapshot, uncompressed_cache,
mark_cache, mark_ranges, reader_settings,
avg_value_size_hints, profile_callback);
}

View File

@ -14,6 +14,7 @@ struct MergeTreeReaderSettings
/// If save_marks_in_cache is false, then, if marks are not in cache,
/// we will load them but won't save in the cache, to avoid evicting other data.
bool save_marks_in_cache = false;
bool convert_nested_to_subcolumns = false;
};
struct MergeTreeWriterSettings