Fix flattening of Array(Tuple(...)) #10259

This commit is contained in:
Alexey Milovidov 2020-04-21 02:44:51 +03:00
parent 4ecc86beca
commit 4cc0269de0
3 changed files with 4 additions and 1 deletions

View File

@ -86,7 +86,8 @@ Block flatten(const Block & block)
{
if (const DataTypeArray * type_arr = typeid_cast<const DataTypeArray *>(elem.type.get()))
{
if (const DataTypeTuple * type_tuple = typeid_cast<const DataTypeTuple *>(type_arr->getNestedType().get()))
const DataTypeTuple * type_tuple = typeid_cast<const DataTypeTuple *>(type_arr->getNestedType().get());
if (type_tuple && type_tuple->haveExplicitNames())
{
const DataTypes & element_types = type_tuple->getElements();
const Strings & names = type_tuple->getElementNames();

View File

@ -17,6 +17,7 @@ namespace Nested
std::string extractTableName(const std::string & nested_name);
/// Replace Array(Tuple(...)) columns to a multiple of Array columns in a form of `column_name.element_name`.
/// only for named tuples that actually represent Nested structures.
Block flatten(const Block & block);
/// Collect Array columns in a form of `column_name.element_name` to single Array(Tuple(...)) column.

View File

@ -61,6 +61,7 @@ public:
/// TODO add ability to rename nested columns
void rename(const String & column_from, const String & column_to);
/// NOTE Must correspond with Nested::flatten function.
void flattenNested(); /// TODO: remove, insert already flattened Nested columns.
bool operator==(const ColumnsDescription & other) const { return columns == other.columns; }