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

Function CheckProjectable

cpp/src/arrow/dataset/projector.cc:26–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace dataset {
25
26Status CheckProjectable(const Schema& from, const Schema& to) {
27 for (const auto& to_field : to.fields()) {
28 ARROW_ASSIGN_OR_RAISE(auto from_field, FieldRef(to_field->name()).GetOneOrNone(from));
29
30 if (from_field == nullptr) {
31 if (to_field->nullable()) continue;
32
33 return Status::TypeError("field ", to_field->ToString(),
34 " is not nullable and does not exist in origin schema ",
35 from);
36 }
37
38 if (from_field->type()->id() == Type::NA) {
39 // promotion from null to any type is supported
40 if (to_field->nullable()) continue;
41
42 return Status::TypeError("field ", to_field->ToString(),
43 " is not nullable but has type ", NullType(),
44 " in origin schema ", from);
45 }
46
47 if (!from_field->type()->Equals(to_field->type())) {
48 return Status::TypeError("fields had matching names but differing types. From: ",
49 from_field->ToString(), " To: ", to_field->ToString());
50 }
51
52 if (from_field->nullable() && !to_field->nullable()) {
53 return Status::TypeError("field ", to_field->ToString(),
54 " is not nullable but is not required in origin schema ",
55 from);
56 }
57 }
58
59 return Status::OK();
60}
61
62} // namespace dataset
63} // namespace arrow

Callers 6

ReplaceSchemaMethod · 0.85
ReplaceSchemaMethod · 0.85
GetFragmentsImplMethod · 0.85
ProjectableToMethod · 0.85
NotProjectableToMethod · 0.85
ReplaceSchemaMethod · 0.85

Calls 9

nullableMethod · 0.80
TypeErrorFunction · 0.50
NullTypeFunction · 0.50
OKFunction · 0.50
fieldsMethod · 0.45
ToStringMethod · 0.45
idMethod · 0.45
typeMethod · 0.45
EqualsMethod · 0.45

Tested by 3

ReplaceSchemaMethod · 0.68
ProjectableToMethod · 0.68
NotProjectableToMethod · 0.68