This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
848e8b7
commit 5cd51a1
Showing
6 changed files
with
301 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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,195 @@ | ||
//! This module defines catalog api for icelake. | ||
|
||
use std::collections::{HashMap, HashSet}; | ||
|
||
use async_trait::async_trait; | ||
use uuid::Uuid; | ||
|
||
use crate::error::Result; | ||
use crate::table::{Namespace, TableIdentifier}; | ||
use crate::types::{ | ||
PartitionField, PartitionSpec, Schema, Snapshot, SnapshotReferenceType, SortOrder, | ||
}; | ||
use crate::Table; | ||
|
||
mod rest; | ||
pub use rest::*; | ||
|
||
/// Catalog definition. | ||
#[async_trait] | ||
pub trait Catalog { | ||
/// Return catalog's name. | ||
fn name(&self) -> &str; | ||
|
||
/// List tables under namespace. | ||
async fn list_tables(&self, ns: &Namespace) -> Result<Vec<TableIdentifier>>; | ||
|
||
/// Creates a table. | ||
async fn create_table( | ||
&self, | ||
table_name: &TableIdentifier, | ||
schema: &Schema, | ||
spec: &PartitionSpec, | ||
location: &str, | ||
props: HashMap<String, String>, | ||
) -> Result<Table>; | ||
|
||
/// Check table exists. | ||
async fn table_exists(&self, table_name: &TableIdentifier) -> Result<bool>; | ||
|
||
/// Drop table. | ||
async fn drop_table(&self, table_name: &TableIdentifier, purge: bool) -> Result<()>; | ||
|
||
/// Rename table. | ||
async fn rename_table(&self, from: &TableIdentifier, to: &TableIdentifier) -> Result<()>; | ||
|
||
/// Load table. | ||
async fn load_table(&self, table_name: &TableIdentifier) -> Result<Table>; | ||
|
||
/// Invalidate table. | ||
async fn invalidate_table(&self, table_name: &TableIdentifier) -> Result<()>; | ||
|
||
/// Register a table using metadata file location. | ||
async fn register_table( | ||
&self, | ||
table_name: &TableIdentifier, | ||
metadata_file_location: &str, | ||
) -> Result<Table>; | ||
|
||
/// Update table. | ||
async fn update_table(&self, udpate_table: &UpdateTable) -> Result<Table>; | ||
} | ||
|
||
/// Update table requirments | ||
pub enum UpdateRquirement { | ||
/// Requirest table exists. | ||
AssertTableDoesNotExist, | ||
/// Requirest current table's uuid . | ||
AssertTableUUID(Uuid), | ||
/// Requirest current table branch's snapshot id. | ||
AssertRefSnapshotID { | ||
/// Branch name | ||
name: String, | ||
/// Snapshot id | ||
snapshot_id: i64, | ||
}, | ||
/// Requirest current table's last assigned field id. | ||
AssertLastAssignedFieldId { | ||
/// Last assigned field id. | ||
last_assigned_field_id: i32, | ||
}, | ||
/// Requirest current table's schema id. | ||
AssertCurrentSchemaID { | ||
/// Schema id | ||
schema_id: i32, | ||
}, | ||
/// Requirest current table's last assigned partition id. | ||
AssertLastAssignedPartitionId { | ||
/// Partition id. | ||
last_assigned_partition_id: i32, | ||
}, | ||
/// Requirest current table's default spec assigned partition id. | ||
AssertDefaultSpecID { | ||
/// Spec id | ||
spec_id: i32, | ||
}, | ||
/// Requirest current table's default spec sort order id. | ||
AssertDefaultSortOrderID { | ||
/// Sort order id. | ||
sort_order_id: i32, | ||
}, | ||
} | ||
|
||
/// Metadata updates. | ||
pub enum MetadataUpdate { | ||
/// Assign uuid. | ||
AssignUuid(Uuid), | ||
/// Upgrade format version. | ||
UpgradeFormatVersion(i32), | ||
/// Add schema | ||
AddSchema { | ||
/// New schema | ||
schema: Schema, | ||
/// Last column id | ||
last_column_id: i32, | ||
}, | ||
/// Set current schema id. | ||
SetCurrentSchema { | ||
/// Schema id. | ||
schema_id: i32, | ||
}, | ||
/// Add partition spec | ||
AddPartitionSpec { | ||
/// Spec id | ||
spec_id: i32, | ||
/// Partiton fields | ||
fields: Vec<PartitionField>, | ||
}, | ||
/// Set default partiton spec. | ||
SetDefaultPartitonSpec { | ||
/// Partiton spec id | ||
spec_id: i32, | ||
}, | ||
/// Add sort order. | ||
AddSortOrder { | ||
/// Sort order | ||
sort_order: SortOrder, | ||
}, | ||
/// Set defaut sort order | ||
SetDefaultSortOrder { | ||
/// Sort order id | ||
sort_order_id: i32, | ||
}, | ||
/// Add snapshot | ||
AddSnapshot { | ||
/// Snapshot | ||
snapshot: Snapshot, | ||
}, | ||
/// Remove snapshot | ||
RemoveSnapshot { | ||
/// Snapshot id | ||
snapshot_id: i64, | ||
}, | ||
/// Remove snapshot ref | ||
RemoveSnapshotRef { | ||
/// Ref name. | ||
ref_name: String, | ||
}, | ||
/// Update snapshot reference. | ||
SetSnapshotRef { | ||
/// Branch name | ||
ref_name: String, | ||
/// Snapshot shot id. | ||
snapshot_id: Option<i64>, | ||
/// Type | ||
typ: SnapshotReferenceType, | ||
/// Number of snapshots to keep. | ||
min_snapshots_to_keep: Option<i32>, | ||
/// Max snapshot ages | ||
max_snapshot_ages: Option<i64>, | ||
/// Max ref ages | ||
max_ref_ages: Option<i64>, | ||
}, | ||
/// Update table properties. | ||
SetProperties { | ||
/// Table properties. | ||
props: HashMap<String, String>, | ||
}, | ||
/// Remove table properties. | ||
RemoveProperties { | ||
/// Keys to remove. | ||
removed: HashSet<String>, | ||
}, | ||
/// Set table location | ||
SetLocation { | ||
/// Table Location | ||
location: String, | ||
}, | ||
} | ||
|
||
/// Update table request. | ||
pub struct UpdateTable { | ||
table_name: TableIdentifier, | ||
requirements: Vec<UpdateRquirement>, | ||
updates: Vec<MetadataUpdate>, | ||
} |
This file contains 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,82 @@ | ||
//! Rest catalog implementation. | ||
//! | ||
|
||
use std::collections::HashMap; | ||
|
||
use async_trait::async_trait; | ||
|
||
use crate::{ | ||
table::{Namespace, TableIdentifier}, | ||
types::{PartitionSpec, Schema}, | ||
Table, | ||
}; | ||
|
||
use super::{Catalog, UpdateTable}; | ||
use crate::error::Result; | ||
|
||
/// Rest catalog implementation | ||
pub struct RestCatalog {} | ||
|
||
#[async_trait] | ||
impl Catalog for RestCatalog { | ||
/// Return catalog's name. | ||
fn name(&self) -> &str { | ||
todo!() | ||
} | ||
|
||
/// List tables under namespace. | ||
async fn list_tables(&self, _ns: &Namespace) -> Result<Vec<TableIdentifier>> { | ||
todo!() | ||
} | ||
|
||
/// Creates a table. | ||
async fn create_table( | ||
&self, | ||
_table_name: &TableIdentifier, | ||
_schema: &Schema, | ||
_spec: &PartitionSpec, | ||
_location: &str, | ||
_props: HashMap<String, String>, | ||
) -> Result<Table> { | ||
todo!() | ||
} | ||
|
||
/// Check table exists. | ||
async fn table_exists(&self, _table_name: &TableIdentifier) -> Result<bool> { | ||
todo!() | ||
} | ||
|
||
/// Drop table. | ||
async fn drop_table(&self, _table_name: &TableIdentifier, _purge: bool) -> Result<()> { | ||
todo!() | ||
} | ||
|
||
/// Rename table. | ||
async fn rename_table(&self, _from: &TableIdentifier, _to: &TableIdentifier) -> Result<()> { | ||
todo!() | ||
} | ||
|
||
/// Load table. | ||
async fn load_table(&self, _table_name: &TableIdentifier) -> Result<Table> { | ||
todo!() | ||
} | ||
|
||
/// Invalidate table. | ||
async fn invalidate_table(&self, _table_name: &TableIdentifier) -> Result<()> { | ||
todo!() | ||
} | ||
|
||
/// Register a table using metadata file location. | ||
async fn register_table( | ||
&self, | ||
_table_name: &TableIdentifier, | ||
_metadata_file_location: &str, | ||
) -> Result<Table> { | ||
todo!() | ||
} | ||
|
||
/// Update table. | ||
async fn update_table(&self, _udpate_table: &UpdateTable) -> Result<Table> { | ||
todo!() | ||
} | ||
} |
This file contains 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 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