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

Method FromNames

cpp/src/arrow/dataset/scanner.cc:845–872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843}
844
845Result<ProjectionDescr> ProjectionDescr::FromNames(std::vector<std::string> names,
846 const Schema& dataset_schema,
847 bool add_augmented_fields) {
848 std::vector<compute::Expression> exprs(names.size());
849 for (size_t i = 0; i < exprs.size(); ++i) {
850 // If name isn't in schema, try finding it by dotted path.
851 if (dataset_schema.GetFieldByName(names[i]) == nullptr) {
852 auto name = names[i];
853 if (name.rfind(".", 0) != 0) {
854 name = "." + name;
855 }
856 ARROW_ASSIGN_OR_RAISE(auto field_ref, FieldRef::FromDotPath(name));
857 // safe as we know there is at least 1 dot.
858 names[i] = name.substr(name.rfind(".") + 1);
859 exprs[i] = compute::field_ref(field_ref);
860 } else {
861 exprs[i] = compute::field_ref(names[i]);
862 }
863 }
864 auto fields = dataset_schema.fields();
865 if (add_augmented_fields) {
866 for (const auto& aug_field : kAugmentedFields) {
867 fields.push_back(aug_field);
868 }
869 }
870 return ProjectionDescr::FromExpressions(std::move(exprs), std::move(names),
871 Schema(fields, dataset_schema.metadata()));
872}
873
874Result<ProjectionDescr> ProjectionDescr::Default(const Schema& dataset_schema,
875 bool add_augmented_fields) {

Callers

nothing calls this directly

Calls 8

field_refFunction · 0.85
substrMethod · 0.80
push_backMethod · 0.80
SchemaClass · 0.50
sizeMethod · 0.45
GetFieldByNameMethod · 0.45
fieldsMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected