syun64 commented on code in PR #955:
URL: https://github.com/apache/iceberg-python/pull/955#discussion_r1688973596


##########
tests/io/test_pyarrow_visitor.py:
##########
@@ -580,3 +594,127 @@ def 
test_pyarrow_schema_ensure_large_types(pyarrow_schema_nested_without_ids: pa
         ),
     ])
     assert 
_pyarrow_schema_ensure_large_types(pyarrow_schema_nested_without_ids) == 
expected_schema
+
+
+@pytest.fixture
+def bound_reference_str() -> BoundReference[Any]:
+    return BoundReference(
+        field=NestedField(1, "string_field", StringType(), required=False), 
accessor=Accessor(position=0, inner=None)
+    )
+
+
+@pytest.fixture
+def bound_reference_float() -> BoundReference[Any]:
+    return BoundReference(
+        field=NestedField(2, "float_field", FloatType(), required=False), 
accessor=Accessor(position=1, inner=None)
+    )
+
+
+@pytest.fixture
+def bound_reference_double() -> BoundReference[Any]:
+    return BoundReference(
+        field=NestedField(3, "double_field", DoubleType(), required=False),
+        accessor=Accessor(position=2, inner=None),
+    )
+
+
+@pytest.fixture
+def bound_eq_str_field(bound_reference_str: BoundReference[Any]) -> 
BoundEqualTo[Any]:
+    return BoundEqualTo(term=bound_reference_str, literal=literal("hello"))
+
+
+@pytest.fixture
+def bound_greater_than_float_field(bound_reference_float: BoundReference[Any]) 
-> BoundGreaterThan[Any]:
+    return BoundGreaterThan(term=bound_reference_float, literal=literal(100))
+
+
+@pytest.fixture
+def bound_is_nan_float_field(bound_reference_float: BoundReference[Any]) -> 
BoundIsNaN[Any]:
+    return BoundIsNaN(bound_reference_float)
+
+
+@pytest.fixture
+def bound_eq_double_field(bound_reference_double: BoundReference[Any]) -> 
BoundEqualTo[Any]:
+    return BoundEqualTo(term=bound_reference_double, literal=literal(False))
+
+
+@pytest.fixture
+def bound_is_null_double_field(bound_reference_double: BoundReference[Any]) -> 
BoundIsNull[Any]:
+    return BoundIsNull(bound_reference_double)
+
+
+def test_collect_null_nan_unmentioned_terms(
+    bound_eq_str_field: BoundEqualTo[Any], bound_is_nan_float_field: 
BoundIsNaN[Any], bound_is_null_double_field: BoundIsNull[Any]
+) -> None:
+    bound_expr = And(
+        Or(And(bound_eq_str_field, bound_is_nan_float_field), 
bound_is_null_double_field), Not(bound_is_nan_float_field)
+    )
+    collector = _NullNaNUnmentionedTermsCollector()
+    collector.collect(bound_expr)
+    assert {f.field.name for f in collector.null_unmentioned_bound_terms} == { 
 # type: ignore
+        "float_field",
+        "string_field",
+    }
+    assert {f.field.name for f in collector.nan_unmentioned_bound_terms} == {  
# type: ignore
+        "string_field",
+        "double_field",
+    }
+    assert {f.field.name for f in collector.is_null_or_not_bound_terms} == {  
# type: ignore
+        "double_field",
+    }
+    assert {f.field.name for f in collector.is_nan_or_not_bound_terms} == 
{"float_field"}  # type: ignore
+
+
+def 
test_collect_null_nan_unmentioned_terms_with_multiple_predicates_on_the_same_term(
+    bound_eq_str_field: BoundEqualTo[Any],
+    bound_greater_than_float_field: BoundGreaterThan[Any],
+    bound_is_nan_float_field: BoundIsNaN[Any],
+    bound_eq_double_field: BoundEqualTo[Any],
+    bound_is_null_double_field: BoundIsNull[Any],
+) -> None:
+    """Test a single term appears multiple places in the expression tree"""
+    bound_expr = And(
+        Or(
+            And(bound_eq_str_field, bound_greater_than_float_field),
+            And(bound_is_nan_float_field, bound_eq_double_field),
+            bound_greater_than_float_field,
+        ),
+        Not(bound_is_null_double_field),
+    )
+    collector = _NullNaNUnmentionedTermsCollector()
+    collector.collect(bound_expr)
+    assert {f.field.name for f in collector.null_unmentioned_bound_terms} == { 
 # type: ignore
+        "float_field",
+        "string_field",
+    }
+    assert {f.field.name for f in collector.nan_unmentioned_bound_terms} == {  
# type: ignore
+        "string_field",
+        "double_field",
+    }
+    assert {f.field.name for f in collector.is_null_or_not_bound_terms} == {  
# type: ignore
+        "double_field",
+    }
+    assert {f.field.name for f in collector.is_nan_or_not_bound_terms} == 
{"float_field"}  # type: ignore
+
+
+def test__expression_to_complementary_pyarrow(

Review Comment:
   nit:
   
   ```suggestion
   def test_expression_to_complementary_pyarrow(
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to