jqin61 commented on code in PR #955: URL: https://github.com/apache/iceberg-python/pull/955#discussion_r1688687715
########## 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, "field_str_unmentioned", StringType(), required=False), accessor=Accessor(position=0, inner=None) + ) + + +@pytest.fixture +def bound_reference_float() -> BoundReference[Any]: + return BoundReference( + field=NestedField(2, "field_float_mentioned_nan", FloatType(), required=False), accessor=Accessor(position=1, inner=None) + ) + + +@pytest.fixture +def bound_reference_double() -> BoundReference[Any]: + return BoundReference( + field=NestedField(3, "field_double_mentioned_null", 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 Review Comment: This type: ignore is due to the similar issue of Term v.s. Reference I mentioned above because only Reference has .field -- 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