diff --git a/src/Dictionaries/CacheDictionary.cpp b/src/Dictionaries/CacheDictionary.cpp index 9aedb655c29..a467b83be7b 100644 --- a/src/Dictionaries/CacheDictionary.cpp +++ b/src/Dictionaries/CacheDictionary.cpp @@ -136,10 +136,18 @@ void CacheDictionary::toParent(const PaddedPODArray { /// Run update on requested keys before fetch from storage const auto & attribute_name = hierarchical_attribute->name; + auto result_type = std::make_shared(); - auto column = getColumnsImpl({attribute_name}, {result_type->createColumn()}, ids, {nullptr}).front(); - const auto & values = assert_cast &>(*column); - out.assign(values.getData()); + auto input_column = result_type->createColumn(); + auto & input_column_typed = assert_cast &>(*input_column); + auto & data = input_column_typed.getData(); + data.insert(ids.begin(), ids.end()); + + auto column = getColumn({attribute_name}, result_type, {std::move(input_column)}, {result_type}, {nullptr}); + const auto & result_column_typed = assert_cast &>(*column); + const auto & result_data = result_column_typed.getData(); + + out.assign(result_data); } else throw Exception("Hierarchy is not supported for complex key CacheDictionary", ErrorCodes::UNSUPPORTED_METHOD); diff --git a/src/Dictionaries/CacheDictionaryStorage.h b/src/Dictionaries/CacheDictionaryStorage.h index 0015aa88aea..105363ca8a8 100644 --- a/src/Dictionaries/CacheDictionaryStorage.h +++ b/src/Dictionaries/CacheDictionaryStorage.h @@ -336,7 +336,7 @@ private: char * place_for_serialized_columns; inline bool isDefault() const { return place_for_serialized_columns == nullptr; } - inline bool setDefault() + inline void setDefault() { place_for_serialized_columns = nullptr; allocated_size_for_columns = 0; diff --git a/src/Dictionaries/DictionaryHelpers.h b/src/Dictionaries/DictionaryHelpers.h index a6d89e2f086..7f652f976a9 100644 --- a/src/Dictionaries/DictionaryHelpers.h +++ b/src/Dictionaries/DictionaryHelpers.h @@ -81,6 +81,7 @@ public: { attributes_to_fetch_filter[i] = true; attributes_default_value_providers.emplace_back(dictionary_attribute.null_value, attributes_default_values_columns[default_values_column_index]); + ++default_values_column_index; } else attributes_default_value_providers.emplace_back(dictionary_attribute.null_value); @@ -172,7 +173,11 @@ static inline void insertDefaultValuesIntoColumns( const auto & default_value_provider = fetch_request.defaultValueProviderAtIndex(column_index); if (fetch_request.shouldFillResultColumnWithIndex(column_index)) + { + std::cerr << "insertDefaultValuesIntoColumns" << default_value_provider.getDefaultValue(row_index).dump() << std::endl; + column->insert(default_value_provider.getDefaultValue(row_index)); + } } }