mathyingzhou commented on a change in pull request #8648: URL: https://github.com/apache/arrow/pull/8648#discussion_r614516746
########## File path: cpp/src/arrow/adapters/orc/adapter_util.cc ########## @@ -410,19 +1087,33 @@ Status GetArrowType(const liborc::Type* type, std::shared_ptr<DataType>* out) { std::vector<std::shared_ptr<Field>> fields; std::vector<int8_t> type_codes; for (int child = 0; child < subtype_count; ++child) { - std::shared_ptr<DataType> elemtype; - RETURN_NOT_OK(GetArrowType(type->getSubtype(child), &elemtype)); - fields.push_back(field("_union_" + std::to_string(child), elemtype)); + std::shared_ptr<DataType> elem_type; + RETURN_NOT_OK(GetArrowType(type->getSubtype(child), &elem_type)); + fields.push_back(field("_union_" + std::to_string(child), elem_type)); type_codes.push_back(static_cast<int8_t>(child)); } *out = sparse_union(fields, type_codes); break; } default: { - return Status::Invalid("Unknown Orc type kind: ", kind); + return Status::Invalid("Unknown Orc type kind: ", type->toString()); Review comment: TypeError is used haha since if default is reached there is indeed some TypeError in ORC. ########## File path: cpp/src/arrow/adapters/orc/adapter_util.cc ########## @@ -410,19 +1087,33 @@ Status GetArrowType(const liborc::Type* type, std::shared_ptr<DataType>* out) { std::vector<std::shared_ptr<Field>> fields; std::vector<int8_t> type_codes; for (int child = 0; child < subtype_count; ++child) { - std::shared_ptr<DataType> elemtype; - RETURN_NOT_OK(GetArrowType(type->getSubtype(child), &elemtype)); - fields.push_back(field("_union_" + std::to_string(child), elemtype)); + std::shared_ptr<DataType> elem_type; + RETURN_NOT_OK(GetArrowType(type->getSubtype(child), &elem_type)); + fields.push_back(field("_union_" + std::to_string(child), elem_type)); type_codes.push_back(static_cast<int8_t>(child)); } *out = sparse_union(fields, type_codes); break; } default: { - return Status::Invalid("Unknown Orc type kind: ", kind); + return Status::Invalid("Unknown Orc type kind: ", type->toString()); } } - return Status::OK(); + return arrow::Status::OK(); +} + +Result<ORC_UNIQUE_PTR<liborc::Type>> GetORCType(const Schema& schema) { + int numFields = schema.num_fields(); + ORC_UNIQUE_PTR<liborc::Type> out_type = liborc::createStructType(); + for (int i = 0; i < numFields; i++) { + std::shared_ptr<Field> field = schema.field(i); + std::string field_name = field->name(); + std::shared_ptr<DataType> arrow_child_type = field->type(); + ORC_UNIQUE_PTR<liborc::Type> orc_subtype = + ::GetORCType(*arrow_child_type).ValueOrDie(); Review comment: Yup. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org