You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "jayceslesar (via GitHub)" <gi...@apache.org> on 2023/12/12 21:09:11 UTC

[PR] WIP: first pass at `UnboundTransform` [iceberg-python]

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

   Resolves https://github.com/apache/iceberg-python/issues/198 


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-4007142244

   @nssalian The issue hasn't been solved unfortunally. I've reopened the issue, but this PR needs a bit more TLD


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

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


##########
tests/expressions/test_parser.py:
##########
@@ -199,3 +200,8 @@ def test_with_function() -> None:
         parser.parse("foo = 1 and lower(bar) = '2'")
 
     assert "Expected end of text, found 'and'" in str(exc_info)
+
+
+def test_cast() -> None:
+    cast = parser.parse("CAST(created_at as date)")

Review Comment:
   I would love to see some more tests here. The most important part that's missing here is converting `date` to a `DayTransform`. Other options such as `year`, `month` etc should be added as well.



-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

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


##########
pyiceberg/transforms.py:
##########
@@ -821,3 +824,34 @@ class BoundTransform(BoundTerm[L]):
     def __init__(self, term: BoundTerm[L], transform: Transform[L, Any]):
         self.term: BoundTerm[L] = term
         self.transform = transform

Review Comment:
   ```suggestion
       def __init__(self, term: BoundTerm[L], transform_func: Callable[Optional[L], Optional[Any]]):
           self.term: BoundTerm[L] = term
           self.transform = transform
   ```



-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "nssalian (via GitHub)" <gi...@apache.org>.
nssalian commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-4087694596

   @Fokko @jayceslesar , I'll take a stab at this and push a new PR if that's ok?


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "jayceslesar (via GitHub)" <gi...@apache.org>.
jayceslesar commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-1854687084

   @Fokko this isnt completely done, but would appreciate a review + some guidance on next steps once you run linting and see whats up haha


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

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

   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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-1866170081

   Hey @jayceslesar thanks for working on this, and I think you're already halfway there. The most important part is to make sure that we convert `as date` to a `DayTransform`.


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

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

   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] WIP: first pass at `UnboundTransform` [iceberg-python]

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


##########
pyiceberg/transforms.py:
##########
@@ -821,3 +824,34 @@ class BoundTransform(BoundTerm[L]):
     def __init__(self, term: BoundTerm[L], transform: Transform[L, Any]):
         self.term: BoundTerm[L] = term
         self.transform = transform
+
+    def eval(self, struct: StructProtocol) -> L:
+        """Return the value at the referenced field's position in an object that abides by the StructProtocol."""
+        return self.term.eval(struct)
+
+    def ref(self) -> BoundReference[L]:
+        """Return the bound reference."""
+        return self.term.ref()
+
+
+class UnboundTransform(UnboundTerm[L]):
+    """An unbound transform expression."""
+
+    transform: Transform[L, Any]
+
+    def __init__(self, term: UnboundTerm[L], transform: Transform[L, Any]):
+        self.term: UnboundTerm[L] = term
+        self.transform = transform
+
+    def bind(self, schema: Schema, case_sensitive: bool = True) -> BoundTransform[L]:
+        bound_term = self.term.bind(schema, case_sensitive)
+
+        if not self.transform.can_transform(bound_term.ref().field.field_type):
+            raise ValueError("some better error message")
+
+        else:
+            return BoundTransform(bound_term, self.transform)

Review Comment:
   I think we should actually instantiate the callable of the transform: 
   ```suggestion
               return BoundTransform(bound_term, self.transform.transform(bound_term.ref().field.field_type))
   ```



##########
pyiceberg/transforms.py:
##########
@@ -821,3 +824,34 @@ class BoundTransform(BoundTerm[L]):
     def __init__(self, term: BoundTerm[L], transform: Transform[L, Any]):
         self.term: BoundTerm[L] = term
         self.transform = transform
+
+    def eval(self, struct: StructProtocol) -> L:
+        """Return the value at the referenced field's position in an object that abides by the StructProtocol."""
+        return self.term.eval(struct)

Review Comment:
   ```suggestion
           return self.transform(self.term.eval(struct))
   ```



-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "nssalian (via GitHub)" <gi...@apache.org>.
nssalian commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-4006427175

   @jayceslesar #198 seems to be closed; do you mind closing this PR so the backlog is cleared?


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "jayceslesar (via GitHub)" <gi...@apache.org>.
jayceslesar commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-1863579944

   No worries on the speed of this one, I know you are heads down on getting write support


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "nssalian (via GitHub)" <gi...@apache.org>.
nssalian commented on PR #209:
URL: https://github.com/apache/iceberg-python/pull/209#issuecomment-4033378938

   Thanks for clarifying @Fokko . @jayceslesar , do you want to pick this back up again and clean it up if you have the bandwidth?


-- 
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] WIP: first pass at `UnboundTransform` [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #209: WIP: first pass at `UnboundTransform`
URL: https://github.com/apache/iceberg-python/pull/209


-- 
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