benibus commented on code in PR #35798:
URL: https://github.com/apache/arrow/pull/35798#discussion_r1210568744
##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -224,6 +224,41 @@ Status ResolveOneFieldRef(
return Status::OK();
}
+bool IsValidFieldRef(const FieldRef& ref) {
+ if (ref.IsName()) return true;
+ if (const auto* nested_refs = ref.nested_refs()) {
+ for (const auto& nested_ref : *nested_refs) {
+ if (!nested_ref.IsName()) return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+// Converts a field ref into a position-independent ref (containing only a
sequence of
+// names) based on the dataset schema. Returns `false` if no conversion was
needed.
+Result<bool> ValidateFieldRef(const FieldRef& ref, const Schema&
dataset_schema,
+ FieldRef* out) {
+ if (ARROW_PREDICT_TRUE(IsValidFieldRef(ref))) {
Review Comment:
Mostly because all existing user code uses named lookups. Plus, I'd imagine
indexed lookups would be fairly rare in practice since it requires knowing the
exact structure (i.e. field order) of the dataset schema upfront, which may not
be predictable if it was inferred from multiple files.
(It's probably not very consequential though)
--
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]