58
58
Reference ,
59
59
)
60
60
from pyiceberg .expressions .visitors import (
61
+ ROWS_CANNOT_MATCH ,
62
+ ROWS_MUST_MATCH ,
61
63
_InclusiveMetricsEvaluator ,
64
+ _StrictMetricsEvaluator ,
62
65
expression_evaluator ,
63
66
inclusive_projection ,
64
67
manifest_evaluator ,
@@ -2745,7 +2748,7 @@ def __init__(
2745
2748
def _build_partition_projection (self , spec_id : int ) -> BooleanExpression :
2746
2749
schema = self ._transaction .table_metadata .schema ()
2747
2750
spec = self ._transaction .table_metadata .specs ()[spec_id ]
2748
- project = visitors . inclusive_projection (schema , spec )
2751
+ project = inclusive_projection (schema , spec )
2749
2752
return project (self ._predicate )
2750
2753
2751
2754
@cached_property
@@ -2755,7 +2758,7 @@ def partition_filters(self) -> KeyDefaultDict[int, BooleanExpression]:
2755
2758
def _build_manifest_evaluator (self , spec_id : int ) -> Callable [[ManifestFile ], bool ]:
2756
2759
schema = self ._transaction .table_metadata .schema ()
2757
2760
spec = self ._transaction .table_metadata .specs ()[spec_id ]
2758
- return visitors . manifest_evaluator (spec , schema , self .partition_filters [spec_id ], case_sensitive = True )
2761
+ return manifest_evaluator (spec , schema , self .partition_filters [spec_id ], case_sensitive = True )
2759
2762
2760
2763
def _build_partition_evaluator (self , spec_id : int ) -> Callable [[DataFile ], bool ]:
2761
2764
schema = self ._transaction .table_metadata .schema ()
@@ -2764,9 +2767,7 @@ def _build_partition_evaluator(self, spec_id: int) -> Callable[[DataFile], bool]
2764
2767
partition_schema = Schema (* partition_type .fields )
2765
2768
partition_expr = self .partition_filters [spec_id ]
2766
2769
2767
- return lambda data_file : visitors .expression_evaluator (partition_schema , partition_expr , case_sensitive = True )(
2768
- data_file .partition
2769
- )
2770
+ return lambda data_file : expression_evaluator (partition_schema , partition_expr , case_sensitive = True )(data_file .partition )
2770
2771
2771
2772
def delete (self , predicate : BooleanExpression ) -> None :
2772
2773
self ._predicate = Or (self ._predicate , predicate )
@@ -2785,8 +2786,8 @@ def _copy_with_new_status(entry: ManifestEntry, status: ManifestEntryStatus) ->
2785
2786
)
2786
2787
2787
2788
manifest_evaluators : Dict [int , Callable [[ManifestFile ], bool ]] = KeyDefaultDict (self ._build_manifest_evaluator )
2788
- strict_metrics_evaluator = visitors . _StrictMetricsEvaluator (schema , self ._predicate , case_sensitive = True ).eval
2789
- inclusive_metrics_evaluator = visitors . _InclusiveMetricsEvaluator (schema , self ._predicate , case_sensitive = True ).eval
2789
+ strict_metrics_evaluator = _StrictMetricsEvaluator (schema , self ._predicate , case_sensitive = True ).eval
2790
+ inclusive_metrics_evaluator = _InclusiveMetricsEvaluator (schema , self ._predicate , case_sensitive = True ).eval
2790
2791
2791
2792
existing_manifests = []
2792
2793
total_deleted_entries = []
@@ -2800,9 +2801,9 @@ def _copy_with_new_status(entry: ManifestEntry, status: ManifestEntryStatus) ->
2800
2801
deleted_entries = []
2801
2802
existing_entries = []
2802
2803
for entry in manifest_file .fetch_manifest_entry (io = self ._io ):
2803
- if strict_metrics_evaluator (entry .data_file ) == visitors . ROWS_MUST_MATCH :
2804
+ if strict_metrics_evaluator (entry .data_file ) == ROWS_MUST_MATCH :
2804
2805
deleted_entries .append (_copy_with_new_status (entry , ManifestEntryStatus .DELETED ))
2805
- elif inclusive_metrics_evaluator (entry .data_file ) == visitors . ROWS_CANNOT_MATCH :
2806
+ elif inclusive_metrics_evaluator (entry .data_file ) == ROWS_CANNOT_MATCH :
2806
2807
existing_entries .append (_copy_with_new_status (entry , ManifestEntryStatus .EXISTING ))
2807
2808
else :
2808
2809
raise ValueError ("Deletes do not support rewrites of data files" )
0 commit comments