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

Function Infer

cpp/src/arrow/json/converter.cc:327–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 }
326
327 std::shared_ptr<DataType> Infer(
328 const std::shared_ptr<Field>& unexpected_field) const override {
329 auto kind = Kind::FromTag(unexpected_field->metadata());
330 switch (kind) {
331 case Kind::kNull:
332 return null();
333
334 case Kind::kBoolean:
335 return boolean();
336
337 case Kind::kNumber:
338 return int64();
339
340 case Kind::kString:
341 return timestamp(TimeUnit::SECOND);
342
343 case Kind::kArray: {
344 const auto& type = checked_cast<const ListType&>(*unexpected_field->type());
345 auto value_field = type.value_field();
346 return list(value_field->WithType(Infer(value_field)));
347 }
348 case Kind::kObject: {
349 auto fields = unexpected_field->type()->fields();
350 for (auto& field : fields) {
351 field = field->WithType(Infer(field));
352 }
353 return struct_(std::move(fields));
354 }
355 default:
356 return nullptr;
357 }
358 }
359
360 std::shared_ptr<DataType> Promote(
361 const std::shared_ptr<DataType>& failed,

Callers 1

PromoteFunction · 0.85

Calls 7

listFunction · 0.85
struct_Function · 0.85
WithTypeMethod · 0.80
timestampFunction · 0.50
metadataMethod · 0.45
typeMethod · 0.45
fieldsMethod · 0.45

Tested by

no test coverage detected