adamreeve commented on code in PR #55665:
URL: https://github.com/apache/arrow/pull/55665#discussion_r4661011497


##########
cpp/src/arrow/dataset/dataset.cc:
##########
@@ -321,6 +323,202 @@ Result<FragmentIterator> 
UnionDataset::GetFragmentsImpl(compute::Expression pred
   return GetFragmentsFromDatasets(children_, predicate);
 }
 
+FilteredFragment::FilteredFragment(std::shared_ptr<Fragment> fragment,
+                                   compute::Expression filter)
+    : Fragment(fragment->partition_expression(), /*physical_schema=*/nullptr),
+      fragment_(std::move(fragment)),
+      filter_(std::move(filter)) {}
+
+Result<std::shared_ptr<Schema>> FilteredFragment::ReadPhysicalSchemaImpl() {
+  return fragment_->ReadPhysicalSchema();
+}
+
+Status FilteredFragment::ClearCachedMetadata() {
+  RETURN_NOT_OK(Fragment::ClearCachedMetadata());
+  return fragment_->ClearCachedMetadata();
+}
+
+std::string FilteredFragment::ToString() const {
+  // The scanner uses ToString() for the __filename augmented field, so this 
must
+  // match the wrapped fragment.
+  return fragment_->ToString();
+}
+
+namespace {
+
+// Bind a FilteredFragment's filter to the dataset schema of the scan options.
+// FilteredFragment can be constructed and scanned directly, so validate the 
inputs.
+Result<compute::Expression> BindFragmentFilter(const compute::Expression& 
filter,
+                                               const ScanOptions& options) {
+  if (options.dataset_schema == nullptr) {
+    return Status::Invalid("Scanning a FilteredFragment requires a dataset 
schema");
+  }
+  ARROW_ASSIGN_OR_RAISE(auto bound, filter.Bind(*options.dataset_schema));

Review Comment:
   I've added an extra check for this in 
f18b83c0872997d1dce5aa1285d3ca0793863b4a



-- 
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]

Reply via email to