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

Function Parse

cpp/src/arrow/dataset/partition_test.cc:1050–1077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1048 }
1049
1050 Result<compute::Expression> Parse(const std::string& path) const override {
1051 std::vector<compute::Expression> ranges;
1052
1053 HivePartitioningOptions options;
1054 for (auto segment : fs::internal::SplitAbstractPath(path)) {
1055 ARROW_ASSIGN_OR_RAISE(auto key, HivePartitioning::ParseKey(segment, options));
1056 if (!key) {
1057 return Status::Invalid("can't parse '", segment, "' as a range");
1058 }
1059
1060 std::smatch matches;
1061 RETURN_NOT_OK(DoRegex(*key->value, &matches));
1062
1063 auto& min_cmp = matches[1] == "[" ? greater_equal : greater;
1064 std::string min_repr = matches[2];
1065 std::string max_repr = matches[3];
1066 auto& max_cmp = matches[4] == "]" ? less_equal : less;
1067
1068 const auto& type = schema_->GetFieldByName(key->name)->type();
1069 ARROW_ASSIGN_OR_RAISE(auto min, Scalar::Parse(type, min_repr));
1070 ARROW_ASSIGN_OR_RAISE(auto max, Scalar::Parse(type, max_repr));
1071
1072 ranges.push_back(and_(min_cmp(field_ref(key->name), literal(min)),
1073 max_cmp(field_ref(key->name), literal(max))));
1074 }
1075
1076 return and_(ranges);
1077 }
1078
1079 static Status DoRegex(const std::string& segment, std::smatch* matches) {
1080 static std::regex re(

Callers

nothing calls this directly

Calls 9

SplitAbstractPathFunction · 0.85
DoRegexFunction · 0.85
and_Function · 0.85
field_refFunction · 0.85
push_backMethod · 0.80
InvalidFunction · 0.50
literalFunction · 0.50
typeMethod · 0.45
GetFieldByNameMethod · 0.45

Tested by

no test coverage detected