You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a short summary of the discussion on the dev list:
Iceberg should allow users to define a sort order in its metadata that applies to partitions.
We should never assume the sort order is actually applied to all files in the table, as that would require rewriting data immediately when we change the sort order.
Sort orders might evolve and change over time. When this happens, existing files will not be rewritten. Query engines should follow the updated sort order during subsequent writes. As a result, files within a table or partition can be sorted differently at a given point in time.
We should be able to define a sort order even for unpartitioned tables, as opposed to current Spark tables that allow a sort order only for bucketed tables.
SortOrder should be separate from PartitionSpec.
SortOrder will rely on transformations to define complex sort orders.
Files will be annotated with sort_order_id instead of sort_columns. We keep the question of file_ordinal open for now.
To begin with, we will support asc/desc natural sort orders (UTF8 ordering for Strings).
Hi @aokolnychyi are you still working on the PR?
By the way, regarding
Sort orders might evolve and change over time. When this happens, existing files will not be rewritten. Query engines should follow the updated sort order during subsequent writes. As a result, files within a table or partition can be sorted differently at a given point in time.
In terms of "changing sort order", do we only support adding new sort order, while it is prohibited to change existing sort orders (especially when they are tied by some data files)?
If it is allowed to change an existing sort order, we could run into problems when visiting the old data files tied to it, right?
@waterlx I have started working on this, but then got distracted by our internal milestones. I hope to submit a PR by the end of this week.
I think it makes sense to follow the same approach as we currently follow for partition spec evolution: we can keep a list of sort orders with their ids in the metadata and files will be annotated with sort_order_id. That way, we can always reconstruct the correct sort order for a file.
@aokolnychyi , thanks for sharing the progress!
I did not make myself clear. Yes, we could change the sort order for partitions. But regarding the individual sort order in the list of sort order in the metadata, is it allowed to change one of them? Say we have a sort order with id =1, sorting on source_column_id = 1 with ascending order, is it supported that it is updated to descending order? Shall we prohibit such kind of change, as it could run into problem when an existing data file is tied it, right? The data file is written with ascending order, but sort order id 1 it tied with says that it is the descending order.
Shall we only add new sort orders but could not change any existing ones?
Maybe this is out of scope for a first cut implementation, but should we also add an API for SortOrder evolution? Something like UpdateSortOrder? So that changes to sort order can be validated, controlled & audited within this API. This API can be accessed using Table.updateSortOrder() maybe?
Activity
aokolnychyi commentedon Jul 29, 2019
I'll submit a PR soon
waterlx commentedon Oct 21, 2019
Hi @aokolnychyi are you still working on the PR?
By the way, regarding
In terms of "changing sort order", do we only support adding new sort order, while it is prohibited to change existing sort orders (especially when they are tied by some data files)?
If it is allowed to change an existing sort order, we could run into problems when visiting the old data files tied to it, right?
aokolnychyi commentedon Oct 21, 2019
@waterlx I have started working on this, but then got distracted by our internal milestones. I hope to submit a PR by the end of this week.
I think it makes sense to follow the same approach as we currently follow for partition spec evolution: we can keep a list of sort orders with their ids in the metadata and files will be annotated with
sort_order_id. That way, we can always reconstruct the correct sort order for a file.waterlx commentedon Oct 23, 2019
@aokolnychyi , thanks for sharing the progress!
I did not make myself clear. Yes, we could change the sort order for partitions. But regarding the individual sort order in the list of sort order in the metadata, is it allowed to change one of them? Say we have a sort order with id =1, sorting on source_column_id = 1 with ascending order, is it supported that it is updated to descending order? Shall we prohibit such kind of change, as it could run into problem when an existing data file is tied it, right? The data file is written with ascending order, but sort order id 1 it tied with says that it is the descending order.
Shall we only add new sort orders but could not change any existing ones?
aokolnychyi commentedon Oct 29, 2019
@waterlx I agree that sort orders should be immutable. If we change the sort order for a table, we should produce a new sort order with a fresh id.
prodeezy commentedon Apr 8, 2020
@aokolnychyi good stuff!
Maybe this is out of scope for a first cut implementation, but should we also add an API for
SortOrderevolution? Something likeUpdateSortOrder? So that changes to sort order can be validated, controlled & audited within this API. This API can be accessed usingTable.updateSortOrder()maybe?aokolnychyi commentedon Sep 4, 2020
Main PR: #1373
rdblue commentedon Oct 28, 2020
This was implemented in #1373.
fix(table): do not claim sort_order_id on files the writer did not fu…