-
Notifications
You must be signed in to change notification settings - Fork 281
feat(transaction): Add TransactionAction POC #1400
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
Draft
CTTY
wants to merge
27
commits into
apache:main
Choose a base branch
from
CTTY:ctty/tx-commit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8ed0ddc
add tx action-ish for set_location (does not work well :(
CTTY d631b3c
Add logic to commit metadata changes (no retry(yet))
CTTY 7a6f3d1
refresh-ish action
CTTY d481d69
minor
CTTY 434cdb6
box things up
CTTY 11260a0
clean up tx.commit
CTTY a64cc21
more cleanup
CTTY f2c3399
clean up, need to fix the referenced logic.. or that could be fixed b…
CTTY f7cb068
More clean up.. retry is not working yet
CTTY 2bfc500
Update crates/iceberg/src/transaction/action/mod.rs
CTTY e881811
Update crates/iceberg/src/transaction/action/mod.rs
CTTY c2baf4e
Have tx own base table, mark tx_commit_res as not used, need to fix r…
CTTY 1c40b86
use backon, code cleanup
CTTY 014726e
minor
CTTY d8a2394
fix test build
CTTY a6ce0b0
fmt
CTTY 88aecf1
Merge branch 'main' into ctty/tx-commit
CTTY 626715c
clean up, add apply()
CTTY 14aea32
Merge branch 'ctty/tx-commit' of github.com:CTTY/iceberg-rust into ct…
CTTY 11bb9d3
remove apply
CTTY 8c2192b
remove tx from FastAppendAction, impl tx action for fast append
CTTY 3ea76bb
fix build and fmt
CTTY 4d1fff8
impl tx_action for update props, replace sort order, and update forma…
CTTY e565f76
Add ApplyTransactionAction, remove mutex and state, stop adding actio…
CTTY 3c0bdd7
removed current_table from tx
CTTY c2dde23
Fix error-handling in retry
CTTY 3a8e8f7
make tx.apply immutable
CTTY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use std::any::Any; | ||
use std::sync::Arc; | ||
|
||
use async_trait::async_trait; | ||
|
||
use crate::transaction::Transaction; | ||
use crate::{Error, ErrorKind, Result, TableRequirement, TableUpdate}; | ||
|
||
pub type BoxedTransactionAction = Arc<dyn TransactionAction>; | ||
|
||
#[async_trait] | ||
pub(crate) trait TransactionAction: Sync + Send { | ||
fn apply(&self) -> Box<dyn Any>; | ||
|
||
/// Commit the changes and apply the changes to the transaction | ||
fn commit(self: Arc<Self>, tx: &mut Transaction) -> Result<()>; | ||
CTTY marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
pub struct UpdateLocationAction { | ||
location: Option<String>, | ||
} | ||
|
||
impl UpdateLocationAction { | ||
pub fn new() -> Self { | ||
UpdateLocationAction { location: None } | ||
} | ||
|
||
pub fn set_location(mut self, location: String) -> Self { | ||
self.location = Some(location); | ||
self | ||
} | ||
} | ||
|
||
CTTY marked this conversation as resolved.
Show resolved
Hide resolved
|
||
impl TransactionAction for UpdateLocationAction { | ||
fn apply(&self) -> Box<dyn Any> { | ||
Box::new(self.location.clone()) | ||
} | ||
|
||
fn commit(self: Arc<Self>, tx: &mut Transaction) -> Result<()> { | ||
let updates: Vec<TableUpdate>; | ||
let requirements: Vec<TableRequirement>; | ||
if let Some(location) = self.location.clone() { | ||
updates = vec![TableUpdate::SetLocation { location }]; | ||
requirements = vec![]; | ||
} else { | ||
return Err(Error::new( | ||
ErrorKind::DataInvalid, | ||
"Location is not set for SetLocation!", | ||
)); | ||
} | ||
|
||
tx.actions.push(self); | ||
|
||
tx.apply(updates, requirements) | ||
CTTY marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.