18
18
use crate :: expr:: visitors:: bound_predicate_visitor:: { visit, BoundPredicateVisitor } ;
19
19
use crate :: expr:: visitors:: inclusive_projection:: InclusiveProjection ;
20
20
use 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 } ;
22
22
use crate :: { Error , ErrorKind } ;
23
23
use fnv:: FnvHashSet ;
24
24
use std:: sync:: Arc ;
@@ -46,6 +46,10 @@ impl ManifestEvaluator {
46
46
let cloned_partition_fields: Vec < _ > =
47
47
partition_type. fields ( ) . iter ( ) . map ( Arc :: clone) . collect ( ) ;
48
48
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
49
53
let partition_schema = Schema :: builder ( )
50
54
. with_schema_id ( partition_spec. spec_id )
51
55
. with_fields ( cloned_partition_fields)
@@ -76,6 +80,9 @@ impl ManifestEvaluator {
76
80
return Ok ( true ) ;
77
81
}
78
82
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
79
86
if self . partition_schema . schema_id ( ) != manifest_file. partition_spec_id {
80
87
return Err ( Error :: new (
81
88
ErrorKind :: Unexpected ,
@@ -90,6 +97,20 @@ impl ManifestEvaluator {
90
97
91
98
visit ( & mut evaluator, & self . partition_filter )
92
99
}
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
+ }
93
114
}
94
115
95
116
struct ManifestFilterVisitor < ' a > {
@@ -266,7 +287,7 @@ impl ManifestFilterVisitor<'_> {
266
287
267
288
#[ cfg( test) ]
268
289
mod test {
269
- use crate :: expr:: visitors:: manifest_evaluator :: ManifestEvaluator ;
290
+ use crate :: expr:: visitors:: inclusive_metrics_evaluator :: ManifestEvaluator ;
270
291
use crate :: expr:: { Bind , Predicate , PredicateOperator , Reference , UnaryExpression } ;
271
292
use crate :: spec:: {
272
293
FieldSummary , ManifestContentType , ManifestFile , NestedField , PartitionField ,
0 commit comments