4747from typing_extensions import Annotated
4848
4949import pyiceberg .expressions .parser as parser
50- import pyiceberg .expressions .visitors as visitors
5150from pyiceberg .exceptions import CommitFailedException , ResolveError , ValidationError
5251from pyiceberg .expressions import (
5352 AlwaysTrue ,
5655 EqualTo ,
5756 Reference ,
5857)
58+ from pyiceberg .expressions .visitors import (
59+ _InclusiveMetricsEvaluator ,
60+ expression_evaluator ,
61+ inclusive_projection ,
62+ manifest_evaluator ,
63+ )
5964from pyiceberg .io import FileIO , load_file_io
6065from pyiceberg .manifest import (
6166 POSITIONAL_DELETE_SCHEMA ,
@@ -1445,9 +1450,7 @@ def _match_deletes_to_data_file(data_entry: ManifestEntry, positional_delete_ent
14451450 relevant_entries = positional_delete_entries [positional_delete_entries .bisect_right (data_entry ) :]
14461451
14471452 if len (relevant_entries ) > 0 :
1448- evaluator = visitors ._InclusiveMetricsEvaluator (
1449- POSITIONAL_DELETE_SCHEMA , EqualTo ("file_path" , data_entry .data_file .file_path )
1450- )
1453+ evaluator = _InclusiveMetricsEvaluator (POSITIONAL_DELETE_SCHEMA , EqualTo ("file_path" , data_entry .data_file .file_path ))
14511454 return {
14521455 positional_delete_entry .data_file
14531456 for positional_delete_entry in relevant_entries
@@ -1471,7 +1474,7 @@ def __init__(
14711474 super ().__init__ (table , row_filter , selected_fields , case_sensitive , snapshot_id , options , limit )
14721475
14731476 def _build_partition_projection (self , spec_id : int ) -> BooleanExpression :
1474- project = visitors . inclusive_projection (self .table .schema (), self .table .specs ()[spec_id ])
1477+ project = inclusive_projection (self .table .schema (), self .table .specs ()[spec_id ])
14751478 return project (self .row_filter )
14761479
14771480 @cached_property
@@ -1480,7 +1483,7 @@ def partition_filters(self) -> KeyDefaultDict[int, BooleanExpression]:
14801483
14811484 def _build_manifest_evaluator (self , spec_id : int ) -> Callable [[ManifestFile ], bool ]:
14821485 spec = self .table .specs ()[spec_id ]
1483- return visitors . manifest_evaluator (spec , self .table .schema (), self .partition_filters [spec_id ], self .case_sensitive )
1486+ return manifest_evaluator (spec , self .table .schema (), self .partition_filters [spec_id ], self .case_sensitive )
14841487
14851488 def _build_partition_evaluator (self , spec_id : int ) -> Callable [[DataFile ], bool ]:
14861489 spec = self .table .specs ()[spec_id ]
@@ -1491,9 +1494,7 @@ def _build_partition_evaluator(self, spec_id: int) -> Callable[[DataFile], bool]
14911494 # The lambda created here is run in multiple threads.
14921495 # So we avoid creating _EvaluatorExpression methods bound to a single
14931496 # shared instance across multiple threads.
1494- return lambda data_file : visitors .expression_evaluator (partition_schema , partition_expr , self .case_sensitive )(
1495- data_file .partition
1496- )
1497+ return lambda data_file : expression_evaluator (partition_schema , partition_expr , self .case_sensitive )(data_file .partition )
14971498
14981499 def _check_sequence_number (self , min_data_sequence_number : int , manifest : ManifestFile ) -> bool :
14991500 """Ensure that no manifests are loaded that contain deletes that are older than the data.
@@ -1538,7 +1539,7 @@ def plan_files(self) -> Iterable[FileScanTask]:
15381539 # this filter depends on the partition spec used to write the manifest file
15391540
15401541 partition_evaluators : Dict [int , Callable [[DataFile ], bool ]] = KeyDefaultDict (self ._build_partition_evaluator )
1541- metrics_evaluator = visitors . _InclusiveMetricsEvaluator (
1542+ metrics_evaluator = _InclusiveMetricsEvaluator (
15421543 self .table .schema (), self .row_filter , self .case_sensitive , self .options .get ("include_empty_files" ) == "true"
15431544 ).eval
15441545
0 commit comments