| 173 | } |
| 174 | |
| 175 | static std::pair<ColumnPtr, DataTypePtr> recursivelyConvertDynamicColumnToTuple( |
| 176 | const ColumnPtr & column, const DataTypePtr & type) |
| 177 | { |
| 178 | if (!type->hasDynamicSubcolumns()) |
| 179 | return {column, type}; |
| 180 | |
| 181 | if (const auto * type_object = typeid_cast<const DataTypeObject *>(type.get())) |
| 182 | { |
| 183 | const auto & column_object = assert_cast<const ColumnObject &>(*column); |
| 184 | return convertObjectColumnToTuple(column_object, *type_object); |
| 185 | } |
| 186 | |
| 187 | if (const auto * type_array = typeid_cast<const DataTypeArray *>(type.get())) |
| 188 | { |
| 189 | const auto & column_array = assert_cast<const ColumnArray &>(*column); |
| 190 | auto [new_column, new_type] = recursivelyConvertDynamicColumnToTuple( |
| 191 | column_array.getDataPtr(), type_array->getNestedType()); |
| 192 | |
| 193 | return |
| 194 | { |
| 195 | ColumnArray::create(new_column, column_array.getOffsetsPtr()), |
| 196 | std::make_shared<DataTypeArray>(std::move(new_type)), |
| 197 | }; |
| 198 | } |
| 199 | |
| 200 | if (const auto * type_map = typeid_cast<const DataTypeMap *>(type.get())) |
| 201 | { |
| 202 | const auto & column_map = assert_cast<const ColumnMap &>(*column); |
| 203 | auto [new_column, new_type] = recursivelyConvertDynamicColumnToTuple( |
| 204 | column_map.getNestedColumnPtr(), type_map->getNestedType()); |
| 205 | |
| 206 | return |
| 207 | { |
| 208 | ColumnMap::create(new_column), |
| 209 | std::make_shared<DataTypeMap>(std::move(new_type)), |
| 210 | }; |
| 211 | } |
| 212 | |
| 213 | if (const auto * type_tuple = typeid_cast<const DataTypeTuple *>(type.get())) |
| 214 | { |
| 215 | const auto & tuple_columns = assert_cast<const ColumnTuple &>(*column).getColumns(); |
| 216 | const auto & tuple_types = type_tuple->getElements(); |
| 217 | |
| 218 | assert(tuple_columns.size() == tuple_types.size()); |
| 219 | const size_t tuple_size = tuple_types.size(); |
| 220 | |
| 221 | Columns new_tuple_columns(tuple_size); |
| 222 | DataTypes new_tuple_types(tuple_size); |
| 223 | |
| 224 | for (size_t i = 0; i < tuple_size; ++i) |
| 225 | { |
| 226 | std::tie(new_tuple_columns[i], new_tuple_types[i]) |
| 227 | = recursivelyConvertDynamicColumnToTuple(tuple_columns[i], tuple_types[i]); |
| 228 | } |
| 229 | |
| 230 | return |
| 231 | { |
| 232 | ColumnTuple::create(new_tuple_columns), |
no test coverage detected