Skip to content
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

feat: First version of rest catalog. #78

Merged
merged 13 commits into from
Oct 28, 2023
4 changes: 4 additions & 0 deletions crates/iceberg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,24 @@ either = "1"
futures = "0.3"
itertools = "0.11"
lazy_static = "1"
log = "^0.4"
murmur3 = "0.5.2"
once_cell = "1"
opendal = "0.40"
ordered-float = "4.0.0"
reqwest = { version = "^0.11", features = ["json"] }
liurenjie1024 marked this conversation as resolved.
Show resolved Hide resolved
rust_decimal = "1.31.0"
serde = { version = "^1.0", features = ["rc"] }
serde_bytes = "0.11.8"
serde_derive = "^1.0"
serde_json = "^1.0"
serde_repr = "0.1.16"
url = "2"
urlencoding = "2"
uuid = "1.4.1"

[dev-dependencies]
mockito = "^1"
pretty_assertions = "1.4.0"
tempdir = "0.3"
tokio = { version = "1", features = ["macros"] }
21 changes: 18 additions & 3 deletions crates/iceberg/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@

//! Catalog API for Apache Iceberg

#[allow(dead_code)]
mod rest;
pub use rest::*;
use serde_derive::{Deserialize, Serialize};

use crate::spec::{PartitionSpec, Schema, SortOrder};
use crate::table::Table;
use crate::Result;
use crate::{Error, ErrorKind, Result};
use async_trait::async_trait;
use std::collections::HashMap;

Expand Down Expand Up @@ -88,6 +93,8 @@ pub trait Catalog {
/// The namespace identifier is a list of strings, where each string is a
/// component of the namespace. It's catalog implementer's responsibility to
/// handle the namespace identifier correctly.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct NamespaceIdent(Vec<String>);

impl NamespaceIdent {
Expand All @@ -97,8 +104,14 @@ impl NamespaceIdent {
}

/// Create a multi-level namespace identifier from vector.
pub fn from_vec(names: Vec<String>) -> Self {
Self(names)
pub fn from_vec(names: Vec<String>) -> Result<Self> {
if names.is_empty() {
return Err(Error::new(
ErrorKind::DataInvalid,
"Namespace identifier can't be empty!",
));
}
Ok(Self(names))
}
}

Expand All @@ -109,6 +122,7 @@ impl AsRef<Vec<String>> for NamespaceIdent {
}

/// Namespace represents a namespace in the catalog.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Namespace {
name: NamespaceIdent,
properties: HashMap<String, String>,
Expand Down Expand Up @@ -137,6 +151,7 @@ impl Namespace {
}

/// TableIdent represents the identifier of a table in the catalog.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct TableIdent {
namespace: NamespaceIdent,
name: String,
Expand Down
Loading
Loading