| 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( |
nothing calls this directly
no test coverage detected