-
Couldn't load subscription status.
- Fork 118
feat(catalog-managed): uc-client commit API #1399
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,30 @@ pub struct Commit { | |
| } | ||
|
|
||
| impl Commit { | ||
| /// Create a new commit to send to UC. By default, `is_disown_commit` is set to false (set with | ||
| /// [`Self::with_disown_commit`]). | ||
| pub fn new( | ||
| version: i64, | ||
| timestamp: i64, | ||
| file_name: impl Into<String>, | ||
| file_size: i64, | ||
| file_modification_timestamp: i64, | ||
| ) -> Self { | ||
| Self { | ||
| version, | ||
| timestamp, | ||
| file_name: file_name.into(), | ||
| file_size, | ||
| file_modification_timestamp, | ||
| is_disown_commit: Some(false), | ||
| } | ||
| } | ||
|
|
||
| pub fn with_disown_commit(mut self, disown: bool) -> Self { | ||
| self.is_disown_commit = Some(disown); | ||
| self | ||
| } | ||
|
|
||
| pub fn timestamp_as_datetime(&self) -> Option<chrono::DateTime<chrono::Utc>> { | ||
| chrono::DateTime::from_timestamp_millis(self.timestamp) | ||
| } | ||
|
|
@@ -58,3 +82,44 @@ impl Commit { | |
| chrono::DateTime::from_timestamp_millis(self.file_modification_timestamp) | ||
| } | ||
| } | ||
|
|
||
| /// Request to commit a new version to the table. It must include either a `commit_info` or | ||
| /// `latest_backfilled_version`. | ||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct CommitRequest { | ||
| pub table_id: String, | ||
| pub table_uri: String, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub commit_info: Option<Commit>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub latest_backfilled_version: Option<i64>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub metadata: Option<serde_json::Value>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub protocol: Option<serde_json::Value>, | ||
| } | ||
|
|
||
| impl CommitRequest { | ||
| pub fn new( | ||
| table_id: impl Into<String>, | ||
| table_uri: impl Into<String>, | ||
| commit_info: Commit, | ||
| latest_backfilled_version: Option<i64>, | ||
| ) -> Self { | ||
| Self { | ||
| table_id: table_id.into(), | ||
| table_uri: table_uri.into(), | ||
| commit_info: Some(commit_info), | ||
| latest_backfilled_version, | ||
| metadata: None, | ||
| protocol: None, | ||
| } | ||
| } | ||
|
|
||
| pub fn with_latest_backfilled_version(mut self, version: i64) -> Self { | ||
| self.latest_backfilled_version = Some(version); | ||
| self | ||
| } | ||
|
|
||
| // TODO: expose metadata/protocol (with_metadata, with_protocol) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we put an issue here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea it will generally be part of the larger effort of supporting better UC APIs so gonna wait on those plans to materialize first (this comment is mostly just a marker) |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.