MCPcopy Create free account
hub / github.com/apache/arrow / GetOrcType

Function GetOrcType

cpp/src/arrow/adapters/orc/util.cc:968–1061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

966}
967
968Result<std::unique_ptr<liborc::Type>> GetOrcType(const DataType& type) {
969 Type::type kind = type.id();
970 switch (kind) {
971 case Type::type::BOOL:
972 return liborc::createPrimitiveType(liborc::TypeKind::BOOLEAN);
973 case Type::type::INT8:
974 return liborc::createPrimitiveType(liborc::TypeKind::BYTE);
975 case Type::type::INT16:
976 return liborc::createPrimitiveType(liborc::TypeKind::SHORT);
977 case Type::type::INT32:
978 return liborc::createPrimitiveType(liborc::TypeKind::INT);
979 case Type::type::INT64:
980 return liborc::createPrimitiveType(liborc::TypeKind::LONG);
981 case Type::type::FLOAT:
982 return liborc::createPrimitiveType(liborc::TypeKind::FLOAT);
983 case Type::type::DOUBLE:
984 return liborc::createPrimitiveType(liborc::TypeKind::DOUBLE);
985 // Use STRING instead of VARCHAR for now, both use UTF-8
986 case Type::type::STRING:
987 case Type::type::LARGE_STRING:
988 return liborc::createPrimitiveType(liborc::TypeKind::STRING);
989 case Type::type::BINARY:
990 case Type::type::LARGE_BINARY:
991 case Type::type::FIXED_SIZE_BINARY:
992 return liborc::createPrimitiveType(liborc::TypeKind::BINARY);
993 case Type::type::DATE32:
994 return liborc::createPrimitiveType(liborc::TypeKind::DATE);
995 case Type::type::DATE64:
996 return liborc::createPrimitiveType(liborc::TypeKind::TIMESTAMP);
997 case Type::type::TIMESTAMP: {
998 const auto& timestamp_type = checked_cast<const TimestampType&>(type);
999 if (!timestamp_type.timezone().empty()) {
1000 // The timestamp values stored in the arrow array are normalized to UTC.
1001 // TIMESTAMP_INSTANT type is always preferred over TIMESTAMP type.
1002 return liborc::createPrimitiveType(liborc::TypeKind::TIMESTAMP_INSTANT);
1003 }
1004 // The timestamp values stored in the arrow array can be in any timezone.
1005 return liborc::createPrimitiveType(liborc::TypeKind::TIMESTAMP);
1006 }
1007 case Type::type::DECIMAL128: {
1008 const uint64_t precision =
1009 static_cast<uint64_t>(checked_cast<const Decimal128Type&>(type).precision());
1010 const uint64_t scale =
1011 static_cast<uint64_t>(checked_cast<const Decimal128Type&>(type).scale());
1012 return liborc::createDecimalType(precision, scale);
1013 }
1014 case Type::type::LIST:
1015 case Type::type::FIXED_SIZE_LIST:
1016 case Type::type::LARGE_LIST: {
1017 const auto& value_field = checked_cast<const BaseListType&>(type).value_field();
1018 ARROW_ASSIGN_OR_RAISE(auto orc_subtype, GetOrcType(*value_field->type()));
1019 SetAttributes(value_field, orc_subtype.get());
1020 return liborc::createListType(std::move(orc_subtype));
1021 }
1022 case Type::type::STRUCT: {
1023 std::unique_ptr<liborc::Type> out_type = liborc::createStructType();
1024 std::vector<std::shared_ptr<Field>> arrow_fields =
1025 checked_cast<const StructType&>(type).fields();

Callers 1

WriteMethod · 0.85

Calls 15

SetAttributesFunction · 0.85
timezoneMethod · 0.80
NotImplementedFunction · 0.50
idMethod · 0.45
emptyMethod · 0.45
precisionMethod · 0.45
scaleMethod · 0.45
getMethod · 0.45
fieldsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected