sanjibansg commented on a change in pull request #12530:
URL: https://github.com/apache/arrow/pull/12530#discussion_r830650465
##########
File path: cpp/src/arrow/dataset/partition.cc
##########
@@ -361,7 +411,32 @@ Result<std::string> DirectoryPartitioning::FormatValues(
break;
}
- return fs::internal::JoinAbstractPath(std::move(segments));
+ return std::make_pair(fs::internal::JoinAbstractPath(std::move(segments)),
"");
+}
+
+Result<std::pair<std::string, std::string>> FilenamePartitioning::FormatValues(
+ const ScalarVector& values) const {
+ std::vector<std::string>
segments(static_cast<size_t>(schema_->num_fields()));
+
+ for (int i = 0; i < schema_->num_fields(); ++i) {
+ if (values[i] != nullptr && values[i]->is_valid) {
+ segments[i] = values[i]->ToString();
+ continue;
+ }
+
+ if (auto illegal_index = NextValid(values, i)) {
+ // XXX maybe we should just ignore keys provided after the first absent
one?
+ return Status::Invalid("No partition key for ",
schema_->field(i)->name(),
+ " but a key was provided subsequently for ",
+ schema_->field(*illegal_index)->name(), ".");
+ }
+
+ // if all subsequent keys are absent we'll just print the available keys
+ break;
Review comment:
Added a test case with only one field, do we need any more changes?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]