You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "hedger9487 (via GitHub)" <gi...@apache.org> on 2026/08/26 01:38:43 UTC

[PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

hedger9487 opened a new pull request, #3854:
URL: https://github.com/apache/iceberg-python/pull/3854

   Closes #3680
   
   # Rationale for this change
   
   `TruncateTransform.satisfies_order_of` previously accessed `self.source_type` (and `other.source_type`), which raised `AttributeError: 'TruncateTransform' object has no attribute '_source_type'` whenever comparing truncate transforms with different widths.
   
   Per the Iceberg spec and matching the Java reference implementation, ordering satisfaction between two truncate transforms depends purely on the width comparison (`self.width >= other.width`).
   
   This PR:
   1. Updates `TruncateTransform.satisfies_order_of` to check `isinstance(other, TruncateTransform)` and compare `self.width >= other.width`.
   2. Adds unit tests covering same/different width comparisons and cross-transform comparisons.
   
   ## Are these changes tested?
   
   Yes, added `test_truncate_satisfies_order_of` in `tests/test_transforms.py`. All tests and pre-commit linters pass cleanly.
   
   ## Are there any user-facing changes?
   
   No.


-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3854:
URL: https://github.com/apache/iceberg-python/pull/3854#issuecomment-5975273858

   This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.


-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #3854: Fix TruncateTransform.satisfies_order_of for different widths (#3680)
URL: https://github.com/apache/iceberg-python/pull/3854


-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3854:
URL: https://github.com/apache/iceberg-python/pull/3854#issuecomment-5851312335

   This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.


-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "hedger9487 (via GitHub)" <gi...@apache.org>.
hedger9487 commented on code in PR #3854:
URL: https://github.com/apache/iceberg-python/pull/3854#discussion_r3868941446


##########
pyiceberg/transforms.py:
##########
@@ -896,11 +896,7 @@ def truncate_func(v: Any) -> Any:
     def satisfies_order_of(self, other: Transform[S, T]) -> bool:
         if self == other:
             return True
-        elif (

Review Comment:
   Makes sense! Took this opportunity to clean up `_source_type` and the `source_type` property as well, and expanded the unit test suite to verify cross-transform comparisons and attribute cleanup.
   
   Thanks for the review, @rambleraptor!



-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "rambleraptor (via GitHub)" <gi...@apache.org>.
rambleraptor commented on code in PR #3854:
URL: https://github.com/apache/iceberg-python/pull/3854#discussion_r3867249081


##########
pyiceberg/transforms.py:
##########
@@ -896,11 +896,7 @@ def truncate_func(v: Any) -> Any:
     def satisfies_order_of(self, other: Transform[S, T]) -> bool:
         if self == other:
             return True
-        elif (

Review Comment:
   It doesn't appear that we use source_type anywhere after this change. Can you take this opportunity to remove it?



-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "rambleraptor (via GitHub)" <gi...@apache.org>.
rambleraptor commented on code in PR #3854:
URL: https://github.com/apache/iceberg-python/pull/3854#discussion_r3875258754


##########
tests/test_transforms.py:
##########
@@ -513,6 +513,37 @@ def test_truncate_method(type_var: PrimitiveType, value: Any, expected_human_str
     assert truncate_transform.satisfies_order_of(truncate_transform)
 
 
+def test_truncate_satisfies_order_of() -> None:
+    # Width comparison
+    assert TruncateTransform(5).satisfies_order_of(TruncateTransform(3))
+    assert TruncateTransform(5).satisfies_order_of(TruncateTransform(5))
+    assert not TruncateTransform(3).satisfies_order_of(TruncateTransform(5))
+    assert TruncateTransform(10).satisfies_order_of(TruncateTransform(1))
+    assert not TruncateTransform(1).satisfies_order_of(TruncateTransform(10))
+    assert TruncateTransform(1).satisfies_order_of(TruncateTransform(1))
+
+    # Cross-transform comparisons
+    assert not TruncateTransform(5).satisfies_order_of(BucketTransform(5))
+    assert not TruncateTransform(5).satisfies_order_of(IdentityTransform())
+    assert not TruncateTransform(5).satisfies_order_of(VoidTransform())
+    assert not TruncateTransform(5).satisfies_order_of(DayTransform())
+    assert not TruncateTransform(5).satisfies_order_of(YearTransform())
+    assert not TruncateTransform(5).satisfies_order_of(UnknownTransform("unknown"))
+
+    # Non-transform comparisons
+    assert not TruncateTransform(5).satisfies_order_of(None)  # type: ignore

Review Comment:
   What were the type errors you saw here? In general, we should try to avoid adding `type: ignore` whenever possible. It usually ends up being a code-sniff for a deeper issue.



-- 
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-unsubscribe@iceberg.apache.org

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


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


Re: [PR] Fix TruncateTransform.satisfies_order_of for different widths (#3680) [iceberg-python]

Posted by "hedger9487 (via GitHub)" <gi...@apache.org>.
hedger9487 commented on code in PR #3854:
URL: https://github.com/apache/iceberg-python/pull/3854#discussion_r3875349736


##########
tests/test_transforms.py:
##########
@@ -513,6 +513,37 @@ def test_truncate_method(type_var: PrimitiveType, value: Any, expected_human_str
     assert truncate_transform.satisfies_order_of(truncate_transform)
 
 
+def test_truncate_satisfies_order_of() -> None:
+    # Width comparison
+    assert TruncateTransform(5).satisfies_order_of(TruncateTransform(3))
+    assert TruncateTransform(5).satisfies_order_of(TruncateTransform(5))
+    assert not TruncateTransform(3).satisfies_order_of(TruncateTransform(5))
+    assert TruncateTransform(10).satisfies_order_of(TruncateTransform(1))
+    assert not TruncateTransform(1).satisfies_order_of(TruncateTransform(10))
+    assert TruncateTransform(1).satisfies_order_of(TruncateTransform(1))
+
+    # Cross-transform comparisons
+    assert not TruncateTransform(5).satisfies_order_of(BucketTransform(5))
+    assert not TruncateTransform(5).satisfies_order_of(IdentityTransform())
+    assert not TruncateTransform(5).satisfies_order_of(VoidTransform())
+    assert not TruncateTransform(5).satisfies_order_of(DayTransform())
+    assert not TruncateTransform(5).satisfies_order_of(YearTransform())
+    assert not TruncateTransform(5).satisfies_order_of(UnknownTransform("unknown"))
+
+    # Non-transform comparisons
+    assert not TruncateTransform(5).satisfies_order_of(None)  # type: ignore

Review Comment:
   Thanks for the catch, @rambleraptor!
   
   The mypy error was:
   `Argument 1 to "satisfies_order_of" has incompatible type "None" (and "str", "int"); expected "Transform[Any, Any]"`
   
   These assertions were initially added as overzealous checks for arbitrary inputs. However, as you noted, the function signature strictly contracts `other: Transform[S, T]`, and `satisfies_order_of` is specifically intended for comparing `Transform` instances (consistent with `IdentityTransform` and others). Testing non-transform types with `# type: ignore` violated the API contract.
   
   I have removed those three non-transform assertions in commit 6ccb30d to keep the test suite strictly typed and eliminate the `# type: ignore` comments.



-- 
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-unsubscribe@iceberg.apache.org

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


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