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

[feat] Support update table's sort order #1245

Open
JasperHG90 opened this issue Oct 22, 2024 · 4 comments · May be fixed by #1500
Open

[feat] Support update table's sort order #1245

JasperHG90 opened this issue Oct 22, 2024 · 4 comments · May be fixed by #1500
Assignees

Comments

@JasperHG90
Copy link

Question

I was playing around with the sort order option and I couldn't find a way to update the sort order of a table. Is this supported? The docs only show how to define a sort order when a table is being created.

Thanks in advance.

@JasperHG90 JasperHG90 changed the title Is it possible to update the sort order of a table after it has been created? Is it possible to update the sort order of a table after the table has been created? Oct 22, 2024
@kevinjqliu
Copy link
Contributor

kevinjqliu commented Nov 6, 2024

hey @JasperHG90
There's actually no public API currently to update sort order for a table. There is an action defined AddSortOrderUpdate.

We probably need something like UpdateSchema and UpdateSpec which is used to update schema and partition spec respectively.

Such as adding update_sort_order function to the Transaction class

@JasperHG90
Copy link
Author

Thanks @kevinjqliu. Is this part of your roadmap? If so, I'd like to take a crack at it.

@kevinjqliu kevinjqliu changed the title Is it possible to update the sort order of a table after the table has been created? Support update table's sort order Nov 6, 2024
@kevinjqliu kevinjqliu changed the title Support update table's sort order [feat] Support update table's sort order Nov 6, 2024
@kevinjqliu
Copy link
Contributor

i didnt find any similar ticket. renamed and assigned to you. Cheers! Please LMK if you have any questions

@Fokko
Copy link
Contributor

Fokko commented Nov 15, 2024

For inspiration we can look at the Java side, there is a method on the table called replaceSortOrder():

I would expect something like, similar to Java:

with table.replace_sort_order() as update:
    update.asc("id")  # identity
    update.desc("user-id", BucketTransform(16))  # Bucket transform

Similar to the partition spec: https://py.iceberg.apache.org/api/#partition-evolution but a bit more straightforward, since in the Spec we update it, and with the sort-order we replace it :) Feel free to reach out if you run into anything!

@JasperHG90 JasperHG90 linked a pull request Jan 8, 2025 that will close this issue
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 a pull request may close this issue.

3 participants