@@ -986,34 +986,17 @@ def visit_or(self, left_result: pc.Expression, right_result: pc.Expression) -> p
986986 return left_result | right_result
987987
988988
989- class _NullNaNUnmentionedTermsCollector (BoundBooleanExpressionVisitor [None ]):
990- # BoundTerms which have either is_null or is_not_null appearing at least once in the boolean expr.
991- is_null_or_not_bound_terms : set [BoundTerm ]
992- # The remaining BoundTerms appearing in the boolean expr.
993- null_unmentioned_bound_terms : set [BoundTerm ]
989+ class _NaNUnmentionedTermsCollector (BoundBooleanExpressionVisitor [None ]):
994990 # BoundTerms which have either is_nan or is_not_nan appearing at least once in the boolean expr.
995991 is_nan_or_not_bound_terms : set [BoundTerm ]
996992 # The remaining BoundTerms appearing in the boolean expr.
997993 nan_unmentioned_bound_terms : set [BoundTerm ]
998994
999995 def __init__ (self ) -> None :
1000996 super ().__init__ ()
1001- self .is_null_or_not_bound_terms = set ()
1002- self .null_unmentioned_bound_terms = set ()
1003997 self .is_nan_or_not_bound_terms = set ()
1004998 self .nan_unmentioned_bound_terms = set ()
1005999
1006- def _handle_explicit_is_null_or_not (self , term : BoundTerm ) -> None :
1007- """Handle the predicate case where either is_null or is_not_null is included."""
1008- if term in self .null_unmentioned_bound_terms :
1009- self .null_unmentioned_bound_terms .remove (term )
1010- self .is_null_or_not_bound_terms .add (term )
1011-
1012- def _handle_null_unmentioned (self , term : BoundTerm ) -> None :
1013- """Handle the predicate case where neither is_null or is_not_null is included."""
1014- if term not in self .is_null_or_not_bound_terms :
1015- self .null_unmentioned_bound_terms .add (term )
1016-
10171000 def _handle_explicit_is_nan_or_not (self , term : BoundTerm ) -> None :
10181001 """Handle the predicate case where either is_nan or is_not_nan is included."""
10191002 if term in self .nan_unmentioned_bound_terms :
@@ -1026,59 +1009,45 @@ def _handle_nan_unmentioned(self, term: BoundTerm) -> None:
10261009 self .nan_unmentioned_bound_terms .add (term )
10271010
10281011 def visit_in (self , term : BoundTerm , literals : set [Any ]) -> None :
1029- self ._handle_null_unmentioned (term )
10301012 self ._handle_nan_unmentioned (term )
10311013
10321014 def visit_not_in (self , term : BoundTerm , literals : set [Any ]) -> None :
1033- self ._handle_null_unmentioned (term )
10341015 self ._handle_nan_unmentioned (term )
10351016
10361017 def visit_is_nan (self , term : BoundTerm ) -> None :
1037- self ._handle_null_unmentioned (term )
10381018 self ._handle_explicit_is_nan_or_not (term )
10391019
10401020 def visit_not_nan (self , term : BoundTerm ) -> None :
1041- self ._handle_null_unmentioned (term )
10421021 self ._handle_explicit_is_nan_or_not (term )
10431022
10441023 def visit_is_null (self , term : BoundTerm ) -> None :
1045- self ._handle_explicit_is_null_or_not (term )
10461024 self ._handle_nan_unmentioned (term )
10471025
10481026 def visit_not_null (self , term : BoundTerm ) -> None :
1049- self ._handle_explicit_is_null_or_not (term )
10501027 self ._handle_nan_unmentioned (term )
10511028
10521029 def visit_equal (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1053- self ._handle_null_unmentioned (term )
10541030 self ._handle_nan_unmentioned (term )
10551031
10561032 def visit_not_equal (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1057- self ._handle_null_unmentioned (term )
10581033 self ._handle_nan_unmentioned (term )
10591034
10601035 def visit_greater_than_or_equal (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1061- self ._handle_null_unmentioned (term )
10621036 self ._handle_nan_unmentioned (term )
10631037
10641038 def visit_greater_than (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1065- self ._handle_null_unmentioned (term )
10661039 self ._handle_nan_unmentioned (term )
10671040
10681041 def visit_less_than (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1069- self ._handle_null_unmentioned (term )
10701042 self ._handle_nan_unmentioned (term )
10711043
10721044 def visit_less_than_or_equal (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1073- self ._handle_null_unmentioned (term )
10741045 self ._handle_nan_unmentioned (term )
10751046
10761047 def visit_starts_with (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1077- self ._handle_null_unmentioned (term )
10781048 self ._handle_nan_unmentioned (term )
10791049
10801050 def visit_not_starts_with (self , term : BoundTerm , literal : Literal [Any ]) -> None :
1081- self ._handle_null_unmentioned (term )
10821051 self ._handle_nan_unmentioned (term )
10831052
10841053 def visit_true (self ) -> None :
@@ -1100,9 +1069,9 @@ def collect(
11001069 self ,
11011070 expr : BooleanExpression ,
11021071 ) -> None :
1103- """Collect bound references categorized by null predicates.
1072+ """Collect bound references categorized by NaN predicates.
11041073
1105- Categorizes by having at least one is_null or is_not_null in the expr and the remaining.
1074+ Categorizes by having at least one is_nan or is_not_nan in the expr and the remaining.
11061075 """
11071076 boolean_expression_visit (expr , self )
11081077
@@ -1128,7 +1097,7 @@ def _expression_to_complementary_pyarrow(expr: BooleanExpression, schema: Schema
11281097 ~ in pyarrow.compute.Expression does not handle null: where expr evaluates to null, Not(expr) is null too
11291098 and the row is dropped. Only the rows where expr is true are deleted, so null is read as false.
11301099 """
1131- collector = _NullNaNUnmentionedTermsCollector ()
1100+ collector = _NaNUnmentionedTermsCollector ()
11321101 collector .collect (expr )
11331102
11341103 # Convert the set of terms to a sorted list so that layout of the expression to build is deterministic.
0 commit comments