Repository navigation
Complete the Delta commit posting functionality - #1169
Conversation
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/1127/files) to review incremental changes. - [**commit_api**](#1127) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1127/files)] - [stack/commit_basic](#1166) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1166/files/725c6b686f9f169fb10d7109dfa2c5ea2cd58a4e..2ec21c04831867e54feef742774af6c7b034dea1)] - [stack/commit_backfill_delete_meta](#1169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1169/files/6d0a2246ce9ded3408587e35355ad46deb22dd2d..711f75644a2ae2559277413d36c8e7118a9bd3ca)] - [stack/commit_get](#1170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1170/files/333883036048eb3c5fc5defd6ad193849b2286a4..3e5b8dfe047577223b7e9decac67725e5f4d6c76)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Add coordinated commits API to the spec Related issue is: #1143 --------- Signed-off-by: Yi Li <[email protected]>
8bf1380 to
1ea697a
Compare
d521665 to
225f939
Compare
|
|
||
| /** Repository for managing coordinated commits for managed Delta tables in Unity Catalog. */ | ||
| public class CommitRepository { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(CommitRepository.class); |
225f939 to
a964314
Compare
183103d to
b992302
Compare
6a2493c to
73a437a
Compare
a0a6278 to
eeebad1
Compare
This commit implements backfill and metadata update functionality for coordinated commits in Unity Catalog: - Backfilling and deletion of old commit metadata - Commit limit enforcement - Table metadata updates via commits - Comprehensive test coverage Signed-off-by: Yi Li <[email protected]>
| * The maximum number of commits allowed per table before backfilling is required. TODO: turn this | ||
| * into a configurable server property. | ||
| */ | ||
| private static final int MAX_NUM_COMMITS_PER_TABLE = 50; |
There was a problem hiding this comment.
lets keep this fairly small. say 10. because number of commits across all the table can get large. so limit of 10 means commit table size 10x # tables.
There was a problem hiding this comment.
also MAX_NUM_UNBACKFILLED_COMMITS_PER_TABLE
btw.. is it backfilling or publishing .. what is the terminology?
There was a problem hiding this comment.
if that feels too long... then you can remove NUM. MAX implies number.
There was a problem hiding this comment.
At this moment the RPC field is still called latest_backfilled_version.
It is also called "backfill" in Delta code like UCCommitCoordinatorClient.java and UCTokenBasedRestClient.java.
In some docs I've seen the word "publish" but almost everywhere in code it's called "backfill".
While the spec draft doc is being discussed this might change in future. But consider that it's already named as "backfill" in RPC field I don't think that would change easily.
There was a problem hiding this comment.
re: 50 vs 10
In real life commits per table should remain 1 or 2 almost all the time as long as the client implements correctly. It should never reach the limit regardless of being 10 or 50.
This limit only exist just in case there's a problem in client implementation, or the table is being committed heavily by different clients like in a load test. It's a safety measure.
I can add this explanation to the comment.
There was a problem hiding this comment.
yes. thank you for adding this.
There was a problem hiding this comment.
and yes. lets use backfill for now and be consistent with everything else.
There was a problem hiding this comment.
lets reduce the number of 10 nonetheless. our set up is much less scalable than any SAAS offering in the cloud.
| private static final int MAX_NUM_COMMITS_PER_TABLE = 50; | ||
|
|
||
| /** | ||
| * The batch size limit for delete operations. Set larger than MAX_NUM_COMMITS_PER_TABLE to handle |
There was a problem hiding this comment.
delete operations of what? how is it related to the MAX_NUM_COMMITS_PER_TABLE
There was a problem hiding this comment.
It's for deletion operations of commits when backfilling or deleting a table.
In real life we should never need this limit. So in theory this is simply redundant when it's bigger than MAX_NUM_COMMITS_PER_TABLE because any commit deletion or selection query execution for a table shouldn't hit more than that many rows. We should feel free to delete or scan the entire 50 max rows without the LIMIT clause.
It's simply yet another safety measure to make sure a single query doesn't cause a huge query execution if something was implemented incorrectly and the number of unbackfilled commits accumulate unbounded.
| DeltaCommit commit, | ||
| DeltaCommitDAO firstCommit, | ||
| DeltaCommitDAO lastCommit) { |
There was a problem hiding this comment.
this is getting complicated. you are taking 3 different commits. this needs param docs. what does first and last mean?
There was a problem hiding this comment.
also make the DAO type params into have DAO in the name to differentiate from non-DAO commit.
| "Latest backfilled version %d cannot be greater than the last commit version = %d", | ||
| latestBackfilledVersion.get(), lastCommitVersion)); | ||
| } | ||
| long effectiveBackfilledVersion = |
There was a problem hiding this comment.
this variable is only used for checking commit limit. cant this be pushed into the checkCommitLimit function? seems like a better abstraction.
| */ | ||
| private static void checkCommitLimit( | ||
| UUID tableId, long effectiveBackfilledVersion, long newCommitVersion) { | ||
| long expectedFirstCommitAfterBackfill = effectiveBackfilledVersion + 1L; |
There was a problem hiding this comment.
this is not
| long expectedFirstCommitAfterBackfill = effectiveBackfilledVersion + 1L; | |
| long expectedFirstVersionAfterBackfill = effectiveBackfilledVersion + 1L; |
lets be consistent on when to use commit and when version.
commit = entire commit object.
version = the commit version, an integer.
please check all the code in this file to see if this is definition is consistent.
5e4aff2 to
4e30f44
Compare
| } | ||
|
|
||
| /** | ||
| * Retrieves the first and last commits for a table ordered by version number. |
There was a problem hiding this comment.
These are not actually first and last commit of the table.. these are the first and last UNBACKFILLED commit of the table .. isnt it?
There was a problem hiding this comment.
Clarified a bit in the comment.
They are the the first and last commit of the table in the database. They may or may not be backfilled already.
For example, in the following order of operation:
- commit v1 (in database there's [v1])
- backfill v1 (in database there's [v1(backfilled)]
- commit v2:
postCommitwill callgetFirstAndLastCommitsand get [v1(backfilled), v1(backfilled)] - commit v3:
postCommitwill callgetFirstAndLastCommitsand get [v1(backfilled), v2]
918108f to
eee17f0
Compare
| * <p>The last commit is the commit in database with the highest version number and latest commit | ||
| * time. | ||
| * |
There was a problem hiding this comment.
is the monotonicity increase of commit timestamp with version number guaranteed?
if so, how? who decides the timestamp?
There was a problem hiding this comment.
Actually there's no guarantee of timestamp as it's sent by client. Removing this wording from this comment.
| if (lastCommitDAO.getIsBackfilledLatestCommit()) { | ||
| // There should only be ONE commit if the last one is marked as backfilled which is the | ||
| // special case. | ||
| if (!Objects.equals(firstCommitDAO.getCommitVersion(), lastCommitDAO.getCommitVersion())) { |
There was a problem hiding this comment.
why do we have to use Objects.equals. its just long isnt it?
There was a problem hiding this comment.
I had Long in the DAO. Now I change them into long.
| } else if (firstCommitDAO.getIsBackfilledLatestCommit()) { | ||
| // The firstCommit is already backfilled. It remains only because it was the only commit | ||
| // left when being backfilled. | ||
| return firstCommitDAO.getCommitVersion(); |
There was a problem hiding this comment.
isnt this an invariant that getIsBackfilledLatestCommit is true if and only if firstCommit = lastCommit?
if so, cant this logic be simplified.
There was a problem hiding this comment.
In this example, it can happen to be [v1(is_backfilled_latest_commit=true), v2]
#1169 (comment)
c5bef70 to
37da1cf
Compare
Signed-off-by: Yi Li <[email protected]>
37da1cf to
6e61c2c
Compare
| TableInfo updatedTable = tableOperations.getTable(fullTableName); | ||
| assertNotNull(updatedTable.getProperties()); | ||
| assertEquals("customValue", updatedTable.getProperties().get("customProperty")); | ||
| assertEquals("enabled", updatedTable.getProperties().get("delta.feature.test")); |
There was a problem hiding this comment.
arent you tested dropping properties?
There was a problem hiding this comment.
Line 579 tested with delta.feature.test dropped.
tdas
left a comment
There was a problem hiding this comment.
LGTM. This was a good completion of the posting functionality.
| * <ul> | ||
| * <li>If the last commit is already marked as backfilled, it remains the backfilled version | ||
| * <li>If the request specifies a valid backfilled version >= first commit, use that | ||
| * <li>If the first commit is marked as backfilled, use its version | ||
| * <li>Otherwise, nothing is backfilled yet (returns firstCommitVersion - 1) | ||
| * </ul> | ||
| * |
There was a problem hiding this comment.
I really liked this example - #1169 (comment)
can put this example in the comment. it made it very clear.
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/1127/files) to review incremental changes. - [**commit_api**](unitycatalog#1127) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1127/files)] - [stack/commit_basic](unitycatalog#1166) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1166/files/725c6b686f9f169fb10d7109dfa2c5ea2cd58a4e..2ec21c04831867e54feef742774af6c7b034dea1)] - [stack/commit_backfill_delete_meta](unitycatalog#1169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1169/files/6d0a2246ce9ded3408587e35355ad46deb22dd2d..711f75644a2ae2559277413d36c8e7118a9bd3ca)] - [stack/commit_get](unitycatalog#1170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1170/files/333883036048eb3c5fc5defd6ad193849b2286a4..3e5b8dfe047577223b7e9decac67725e5f4d6c76)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Add coordinated commits API to the spec Related issue is: unitycatalog#1143 --------- Signed-off-by: Yi Li <[email protected]>
) Use this [link](https://github.com/unitycatalog/unitycatalog/pull/1166/files) to review incremental changes. - [**stack/commit_basic**](unitycatalog#1166) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1166/files)] - [stack/commit_api_2](unitycatalog#1199) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1199/files/8c6992aaad6b981ef38a4fb468ef700f083ad49a..d0d4f606101bc705a6a79514a2b4ba31b2b19b19)] - [stack/commit_backfill_delete_meta](unitycatalog#1169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1169/files/d0d4f606101bc705a6a79514a2b4ba31b2b19b19..93dc85893930d1594b3a974cc48228c767f826ab)] - [stack/commit_get](unitycatalog#1170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1170/files/93dc85893930d1594b3a974cc48228c767f826ab..0e7306a1c14f5476eeef78953b948fd2f7ba0453)] - [stack/commit_access_test](unitycatalog#1178) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1178/files/0e7306a1c14f5476eeef78953b948fd2f7ba0453..6042111d1b885fc5a9cf687b670c98b95ade14d7)] - [stack/ccv2_spark](unitycatalog#1186) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1186/files/6042111d1b885fc5a9cf687b670c98b95ade14d7..cc09752cb91d6c9e6bf474ebc05c82f7a0da95cc)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** This commit adds API support for committing Delta table versions to Unity Catalog with coordinated commit semantics. When multiple clients attempt to commit the same version simultaneously, UC guarantees that only one will succeed. Key features: - POST endpoint at /delta/preview/commits for committing new table versions - Strict sequential version validation (version N+1 must follow version N) - Onboarding flow for tables with no existing commits - Comprehensive validation of commit metadata and table properties - Only managed delta tables are supported Known limitations (documented in code): - Table metadata updates not yet implemented - Backfill of commits not yet supported - Cleanup of commits when deleting tables not yet implemented - RPC support for reading commit lists not yet implemented **Related issue** unitycatalog#1143 --------- Signed-off-by: Yi Li <[email protected]>
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/1199/files) to review incremental changes. - [**stack/commit_api_2**](unitycatalog#1199) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1199/files)] - [stack/commit_backfill_delete_meta](unitycatalog#1169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1169/files/a78dfb470b5128f01ee6c44ccadea2473005a8a2..5e4aff2b0ec2c0518c3ff718d1dfda965d6ff1f5)] - [stack/commit_get](unitycatalog#1170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1170/files/5e4aff2b0ec2c0518c3ff718d1dfda965d6ff1f5..60a3cc2d4e2ef30ee1853a23f2f46f5d00fbc261)] - [stack/commit_access_test](unitycatalog#1178) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1178/files/60a3cc2d4e2ef30ee1853a23f2f46f5d00fbc261..dae5d6f57ba8bb0e16037bab00de9393da1553c0)] - [stack/ccv2_spark](unitycatalog#1186) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1186/files/dae5d6f57ba8bb0e16037bab00de9393da1553c0..be0473cf83f0e100142403a0134409658dc9760a)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Update DeltaCommits API - Change getCommits api to use json payload for its parameters. This is the method actually used by Delta Spark - Rename CoordinatedCommits to DeltaCommits in API **Related issue** unitycatalog#1143 --------- Signed-off-by: Yi Li <[email protected]>
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/1169/files) to review incremental changes. - [**stack/commit_backfill_delete_meta**](unitycatalog#1169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1169/files)] - [stack/commit_get](unitycatalog#1170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1170/files/eee17f0c3f9e6a456523fb0bf502b560a31ddea7..6e1ceb0c6747f1c85bc344b25b6d982dc964a8b3)] - [stack/commit_access_test](unitycatalog#1178) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1178/files/6e1ceb0c6747f1c85bc344b25b6d982dc964a8b3..7cb3ace271839563449be4a900f5260633c423b5)] - [stack/ccv2_spark](unitycatalog#1186) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/1186/files/7cb3ace271839563449be4a900f5260633c423b5..72eff6e86a48ecdcddbd407a5d7f5edabad35a7c)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** This commit implements backfill and metadata update functionality for Delta commits in Unity Catalog: - Backfilling and deletion of old commit metadata - Commit limit enforcement - Table metadata updates via commits - Comprehensive test coverage **Related issue** unitycatalog#1143 --------- Signed-off-by: Yi Li <[email protected]>
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
This commit implements backfill and metadata update functionality for Delta commits in Unity Catalog:
Related issue
#1143