1818use crate :: expr:: visitors:: bound_predicate_visitor:: { visit, BoundPredicateVisitor } ;
1919use crate :: expr:: visitors:: inclusive_projection:: InclusiveProjection ;
2020use crate :: expr:: { Bind , BoundPredicate , BoundReference } ;
21- use crate :: spec:: { Datum , FieldSummary , ManifestFile , PartitionSpecRef , Schema , SchemaRef } ;
21+ use crate :: spec:: { Datum , FieldSummary , ManifestEntry , ManifestFile , PartitionSpecRef , Schema , SchemaRef } ;
2222use crate :: { Error , ErrorKind } ;
2323use fnv:: FnvHashSet ;
2424use std:: sync:: Arc ;
@@ -46,6 +46,10 @@ impl ManifestEvaluator {
4646 let cloned_partition_fields: Vec < _ > =
4747 partition_type. fields ( ) . iter ( ) . map ( Arc :: clone) . collect ( ) ;
4848
49+ // The partition_schema's schema_id is set to the partition
50+ // spec's spec_id here, and used to perform a sanity check
51+ // during eval to confirm that it matches the spec_id
52+ // of the ManifestFile we're evaluating
4953 let partition_schema = Schema :: builder ( )
5054 . with_schema_id ( partition_spec. spec_id )
5155 . with_fields ( cloned_partition_fields)
@@ -76,6 +80,9 @@ impl ManifestEvaluator {
7680 return Ok ( true ) ;
7781 }
7882
83+ // The schema_id of self.partition_schema is set to the
84+ // spec_id of the partition spec that this ManifestEvaluator
85+ // was created from in ManifestEvaluator::new
7986 if self . partition_schema . schema_id ( ) != manifest_file. partition_spec_id {
8087 return Err ( Error :: new (
8188 ErrorKind :: Unexpected ,
@@ -90,6 +97,20 @@ impl ManifestEvaluator {
9097
9198 visit ( & mut evaluator, & self . partition_filter )
9299 }
100+
101+ /// Evaluate this `ManifestEvaluator`'s filter predicate against the
102+ /// provided [`ManifestEntry`]'s partition. Used by [`TableScan`] to
103+ /// see if this `ManifestEntry` could possibly contain data that matches
104+ /// the scan's filter.
105+ pub ( crate ) fn eval_data_file ( & self , manifest_file : & ManifestFile , manifest_entry : & ManifestEntry ) -> crate :: Result < bool > {
106+ if manifest_entry. data_file ( ) . partition . empty ( ) {
107+ return Ok ( true ) ;
108+ }
109+
110+ let mut evaluator = ManifestFilterVisitor :: new ( self , & manifest_file. partitions ) ;
111+
112+ visit ( & mut evaluator, & self . partition_filter )
113+ }
93114}
94115
95116struct ManifestFilterVisitor < ' a > {
@@ -266,7 +287,7 @@ impl ManifestFilterVisitor<'_> {
266287
267288#[ cfg( test) ]
268289mod test {
269- use crate :: expr:: visitors:: manifest_evaluator :: ManifestEvaluator ;
290+ use crate :: expr:: visitors:: inclusive_metrics_evaluator :: ManifestEvaluator ;
270291 use crate :: expr:: { Bind , Predicate , PredicateOperator , Reference , UnaryExpression } ;
271292 use crate :: spec:: {
272293 FieldSummary , ManifestContentType , ManifestFile , NestedField , PartitionField ,
0 commit comments