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

Function GetArrowType

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

Source from the content-addressed store, hash-verified

1086}
1087
1088Result<std::shared_ptr<DataType>> GetArrowType(const liborc::Type* type) {
1089 // When subselecting fields on read, liborc will set some nodes to nullptr,
1090 // so we need to check for nullptr before progressing
1091 if (type == nullptr) {
1092 return null();
1093 }
1094 liborc::TypeKind kind = type->getKind();
1095 const int subtype_count = static_cast<int>(type->getSubtypeCount());
1096
1097 switch (kind) {
1098 case liborc::BOOLEAN:
1099 return boolean();
1100 case liborc::BYTE:
1101 return int8();
1102 case liborc::SHORT:
1103 return int16();
1104 case liborc::INT:
1105 return int32();
1106 case liborc::LONG:
1107 return int64();
1108 case liborc::FLOAT:
1109 return float32();
1110 case liborc::DOUBLE:
1111 return float64();
1112 case liborc::CHAR:
1113 case liborc::VARCHAR:
1114 case liborc::STRING:
1115 return utf8();
1116 case liborc::BINARY:
1117 return binary();
1118 case liborc::TIMESTAMP:
1119 // Values of TIMESTAMP type are stored in the writer timezone in the Orc file.
1120 // Values are read back in the reader timezone. However, the writer timezone
1121 // information in the Orc stripe footer is optional and may be missing. What is
1122 // more, stripes in the same Orc file may have different writer timezones (though
1123 // unlikely). So we cannot tell the exact timezone of values read back in the
1124 // arrow::TimestampArray. In the adapter implementations, we set both writer and
1125 // reader timezone to UTC to avoid any conversion so users can get the same values
1126 // as written. To get rid of this burden, TIMESTAMP_INSTANT type is always preferred
1127 // over TIMESTAMP type.
1128 return timestamp(TimeUnit::NANO);
1129 case liborc::TIMESTAMP_INSTANT:
1130 // Values of TIMESTAMP_INSTANT type are stored in the UTC timezone in the ORC file.
1131 // Both read and write use the UTC timezone without any conversion.
1132 return timestamp(TimeUnit::NANO, "UTC");
1133 case liborc::DATE:
1134 return date32();
1135 case liborc::DECIMAL: {
1136 const int precision = static_cast<int>(type->getPrecision());
1137 const int scale = static_cast<int>(type->getScale());
1138 if (precision == 0) {
1139 // In HIVE 0.11/0.12 precision is set as 0, but means max precision
1140 return decimal128(38, 6);
1141 }
1142 return decimal128(precision, scale);
1143 }
1144 case liborc::LIST: {
1145 if (subtype_count != 1) {

Callers

nothing calls this directly

Calls 7

listFunction · 0.85
struct_Function · 0.85
sparse_unionFunction · 0.85
timestampFunction · 0.50
decimal128Function · 0.50
TypeErrorFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected