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

Function ARROW_ASSIGN_OR_RAISE

cpp/src/arrow/integration/json_internal.cc:1250–1667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1248 const auto& key_value_pair = val.GetObject();
1249
1250 ARROW_ASSIGN_OR_RAISE(const auto key, GetMemberString(key_value_pair, "key"));
1251 ARROW_ASSIGN_OR_RAISE(const auto value, GetMemberString(key_value_pair, "value"));
1252
1253 metadata->Append(std::move(key), std::move(value));
1254 }
1255 return metadata;
1256}
1257
1258Result<std::shared_ptr<Field>> GetField(const rj::Value& obj, FieldPosition field_pos,
1259 DictionaryMemo* dictionary_memo) {
1260 if (!obj.IsObject()) {
1261 return Status::Invalid("Field was not a JSON object");
1262 }
1263 const auto& json_field = obj.GetObject();
1264
1265 ARROW_ASSIGN_OR_RAISE(const auto name, GetMemberString(json_field, "name"));
1266 ARROW_ASSIGN_OR_RAISE(const bool nullable, GetMemberBool(json_field, "nullable"));
1267
1268 ARROW_ASSIGN_OR_RAISE(const auto json_type, GetMemberObject(json_field, "type"));
1269 ARROW_ASSIGN_OR_RAISE(const auto json_children, GetMemberArray(json_field, "children"));
1270
1271 ARROW_ASSIGN_OR_RAISE(FieldVector children,
1272 GetFieldsFromArray(json_children, field_pos, dictionary_memo));
1273 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<DataType> type, GetType(json_type, children));
1274
1275 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<KeyValueMetadata> metadata,
1276 GetKeyValueMetadata(json_field));
1277
1278 // Is it a dictionary type?
1279 int64_t dictionary_id = -1;
1280 std::shared_ptr<DataType> dict_value_type;
1281 const auto& it_dictionary = json_field.FindMember("dictionary");
1282 if (dictionary_memo != nullptr && it_dictionary != json_field.MemberEnd()) {
1283 // Parse dictionary id in JSON and add dictionary field to the
1284 // memo, and parse the dictionaries later
1285 RETURN_NOT_OBJECT("dictionary", it_dictionary, json_field);
1286 bool is_ordered{};
1287 std::shared_ptr<DataType> index_type;
1288 RETURN_NOT_OK(ParseDictionary(it_dictionary->value.GetObject(), &dictionary_id,
1289 &is_ordered, &index_type));
1290
1291 dict_value_type = type;
1292 type = ::arrow::dictionary(index_type, type, is_ordered);
1293 }
1294
1295 // Is it an extension type?
1296 int ext_name_index = metadata->FindKey(kExtensionTypeKeyName);
1297 if (ext_name_index != -1) {
1298 const auto& ext_name = metadata->value(ext_name_index);
1299 ARROW_ASSIGN_OR_RAISE(auto ext_data, metadata->Get(kExtensionMetadataKeyName));
1300
1301 auto ext_type = GetExtensionType(ext_name);
1302 if (ext_type == nullptr) {
1303 // Some integration tests check that unregistered extensions pass through
1304 auto maybe_value = metadata->Get("ARROW:integration:allow_unregistered_extension");
1305 if (!maybe_value.ok() || *maybe_value != "true") {
1306 return Status::KeyError("Extension type '", ext_name, "' not found");
1307 }

Calls 15

GetMemberStringFunction · 0.85
GetMemberBoolFunction · 0.85
GetMemberObjectFunction · 0.85
GetMemberArrayFunction · 0.85
GetFieldsFromArrayFunction · 0.85
GetKeyValueMetadataFunction · 0.85
ParseDictionaryFunction · 0.85
GetExtensionTypeFunction · 0.85
KeyErrorFunction · 0.85
ZipClass · 0.85
GetStringViewFunction · 0.85
ParseHexValueFunction · 0.85

Tested by 2

ConvertArrowToJsonFunction · 0.56
ValidateArrowVsJsonFunction · 0.56