Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(python): Expose transform as a submodule for pyiceberg_core #628

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented Sep 11, 2024

This PR will expose transform as a submodule for pyiceberg_core.

Also, this PR removes not useful hello_world function.

@Xuanwo
Copy link
Member Author

Xuanwo commented Sep 11, 2024

Hi, @sungwy, would you like to take a review? I believe this way is more pythonic.

Copy link
Contributor

@sungwy sungwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Xuanwo thank you for putting up this PR - in hindsight, I agree that this approach is better.

There's an outstanding issue with pyo3 that prevents the functions defined within a module to be imported like below:

from pyiceberg_core.transform import identity, bucket, year, day, month, hour, truncate

This will result in:

ModuleNotFoundError: No module named 'pyiceberg_core.transform'

In my original PR, I decided that exposing a class and static methods instead of a module would save us from this confusion. But I think it makes sense to settle on module pyiceberg.transform in the hope that this issue will be resolved in the future.

@Xuanwo
Copy link
Member Author

Xuanwo commented Sep 11, 2024

There's an outstanding issue with pyo3 that prevents the functions defined within a module to be imported like below:

Oh, I see the problem. Let me take a look.

Signed-off-by: Xuanwo <github@xuanwo.io>
@Xuanwo
Copy link
Member Author

Xuanwo commented Sep 11, 2024

Hi, @sungwy, I fixed this issue and add a test for it. Please take a look, thanks!

Signed-off-by: Xuanwo <github@xuanwo.io>
Copy link
Contributor

@sungwy sungwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man that's amazing. Thank you for the fix!

Copy link

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, thanks for the refactor! added a minor comment.
I'll also refactor #604 to follow this format.

pub fn truncate(py: Python, array: PyObject, width: u32) -> PyResult<PyObject> {
apply(py, array, Transform::Truncate(width))
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add them in follow up PRs?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg!

@Xuanwo
Copy link
Member Author

Xuanwo commented Sep 11, 2024

Thank you @sungwy and @kevinjqliu for the quick review. We can implement more transforms in following PRs. And I will merge this one first 😘

@Xuanwo Xuanwo merged commit eae9464 into apache:main Sep 11, 2024
17 checks passed
@Xuanwo Xuanwo deleted the fix-python branch September 11, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants