The random array generator fills random unselected values in the child arrays of SparseUnionArray. However, orc file only contains dense union type meaning that these unselected values will not be written to the file (so we can never read them back and compare equality in the unit test). Because the orc reader fills unselected values to nulls when reading from the file. So flattening the SparseUni
| 1050 | // fills unselected values to nulls when reading from the file. So flattening |
| 1051 | // the SparseUnionArray before writing makes it easy for the array equality check. |
| 1052 | std::shared_ptr<Array> FlattenSparseUnionArray(std::shared_ptr<Array> array) { |
| 1053 | auto union_array = checked_pointer_cast<SparseUnionArray>(array); |
| 1054 | ArrayVector children; |
| 1055 | for (int i = 0; i < array->num_fields(); ++i) { |
| 1056 | ASSIGN_OR_ABORT(auto flattened_child, union_array->GetFlattenedField(i)); |
| 1057 | children.emplace_back(std::move(flattened_child)); |
| 1058 | } |
| 1059 | return std::make_shared<SparseUnionArray>(array->type(), array->length(), |
| 1060 | std::move(children), |
| 1061 | union_array->type_codes(), array->offset()); |
| 1062 | } |
| 1063 | |
| 1064 | void TestUnionConversion(std::shared_ptr<Array> array) { |
| 1065 | auto length = array->length(); |
no test coverage detected