This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
6defa34
commit 5844876
Showing
66 changed files
with
21,744 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ Cargo.lock | |
*.pdb | ||
|
||
# macOS resource forks and .DS_Store files | ||
.DS_Store | ||
.DS_Store | ||
|
||
.vscode |
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 |
---|---|---|
@@ -1,8 +1,72 @@ | ||
[package] | ||
name = "catalog2" | ||
version = "0.1.0" | ||
# 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. | ||
|
||
[workspace] | ||
resolver = "2" | ||
members = ["crates/rest", "crates/examples", "crates/iceberg", "crates/test_utils"] | ||
|
||
[workspace.package] | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
license = "Apache-2.0" | ||
repository = "https://github.com/cmu-db/15721-s24-catalog2" | ||
rust-version = "1.75.0" | ||
|
||
[dependencies] | ||
[workspace.dependencies] | ||
anyhow = "1.0.72" | ||
apache-avro = "0.16" | ||
arrow-arith = { version = ">=46" } | ||
arrow-array = { version = ">=46" } | ||
arrow-schema = { version = ">=46" } | ||
async-trait = "0.1" | ||
bimap = "0.6" | ||
bitvec = "1.0.1" | ||
chrono = "0.4" | ||
derive_builder = "0.13.0" | ||
either = "1" | ||
env_logger = "0.11.0" | ||
futures = "0.3" | ||
iceberg = { path = "./crates/iceberg" } | ||
iceberg-catalog-rest = { path = "./crates/rest" } | ||
itertools = "0.12" | ||
lazy_static = "1" | ||
log = "^0.4" | ||
mockito = "^1" | ||
murmur3 = "0.5.2" | ||
once_cell = "1" | ||
opendal = "0.45" | ||
ordered-float = "4.0.0" | ||
pretty_assertions = "1.4.0" | ||
port_scanner = "0.1.5" | ||
reqwest = { version = "^0.11", features = ["json"] } | ||
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" | ||
serde_with = "3.4.0" | ||
tempfile = "3.8" | ||
tokio = { version = "1", features = ["macros"] } | ||
typed-builder = "^0.18" | ||
url = "2" | ||
urlencoding = "2" | ||
uuid = "1.6.1" | ||
volo-thrift = "0.9.2" | ||
hive_metastore = "0.0.2" | ||
tera = "1" |
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,50 @@ | ||
# 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. | ||
|
||
.EXPORT_ALL_VARIABLES: | ||
|
||
RUST_LOG = debug | ||
|
||
build: | ||
cargo build | ||
|
||
check-fmt: | ||
cargo fmt --all -- --check | ||
|
||
check-clippy: | ||
cargo clippy --all-targets --all-features --workspace -- -D warnings | ||
|
||
cargo-sort: | ||
cargo install cargo-sort | ||
cargo sort -c -w | ||
|
||
fix-toml: | ||
cargo install taplo-cli --locked | ||
taplo fmt | ||
|
||
check-toml: | ||
cargo install taplo-cli --locked | ||
taplo check | ||
|
||
check: check-fmt check-clippy cargo-sort check-toml | ||
|
||
unit-test: | ||
cargo test --no-fail-fast --lib --all-features --workspace | ||
|
||
test: | ||
cargo test --no-fail-fast --all-targets --all-features --workspace | ||
cargo test --no-fail-fast --doc --all-features --workspace |
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,37 @@ | ||
# 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. | ||
|
||
[package] | ||
name = "iceberg-examples" | ||
version = { workspace = true } | ||
edition = { workspace = true } | ||
repository = { workspace = true } | ||
license = { workspace = true } | ||
rust-version = { workspace = true } | ||
|
||
[dependencies] | ||
iceberg = { workspace = true } | ||
iceberg-catalog-rest = { workspace = true } | ||
tokio = { version = "1", features = ["full"] } | ||
|
||
[[example]] | ||
name = "rest-catalog-namespace" | ||
path = "src/rest_catalog_namespace.rs" | ||
|
||
[[example]] | ||
name = "rest-catalog-table" | ||
path = "src/rest_catalog_table.rs" |
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,21 @@ | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
Example usage codes for `iceberg-rust`. Currently, these examples can't run directly since it requires setting up of | ||
environments for catalogs, for example, rest catalog server. |
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,53 @@ | ||
// 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 iceberg::{Catalog, NamespaceIdent}; | ||
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig}; | ||
use std::collections::HashMap; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// ANCHOR: create_catalog | ||
// Create catalog | ||
let config = RestCatalogConfig::builder() | ||
.uri("http://localhost:8080".to_string()) | ||
.build(); | ||
|
||
let catalog = RestCatalog::new(config).await.unwrap(); | ||
// ANCHOR_END: create_catalog | ||
|
||
// ANCHOR: list_all_namespace | ||
// List all namespaces | ||
let all_namespaces = catalog.list_namespaces(None).await.unwrap(); | ||
println!("Namespaces in current catalog: {:?}", all_namespaces); | ||
// ANCHOR_END: list_all_namespace | ||
|
||
// ANCHOR: create_namespace | ||
let namespace_id = | ||
NamespaceIdent::from_vec(vec!["ns1".to_string(), "ns11".to_string()]).unwrap(); | ||
// Create namespace | ||
let ns = catalog | ||
.create_namespace( | ||
&namespace_id, | ||
HashMap::from([("key1".to_string(), "value1".to_string())]), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
println!("Namespace created: {:?}", ns); | ||
// ANCHOR_END: create_namespace | ||
} |
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,68 @@ | ||
// 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 iceberg::spec::{NestedField, PrimitiveType, Schema, Type}; | ||
use iceberg::{Catalog, TableCreation, TableIdent}; | ||
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig}; | ||
use std::collections::HashMap; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Create catalog | ||
let config = RestCatalogConfig::builder() | ||
.uri("http://localhost:8080".to_string()) | ||
.build(); | ||
|
||
let catalog = RestCatalog::new(config).await.unwrap(); | ||
|
||
// ANCHOR: create_table | ||
let table_id = TableIdent::from_strs(["default", "t1"]).unwrap(); | ||
|
||
let table_schema = Schema::builder() | ||
.with_fields(vec![ | ||
NestedField::optional(1, "foo", Type::Primitive(PrimitiveType::String)).into(), | ||
NestedField::required(2, "bar", Type::Primitive(PrimitiveType::Int)).into(), | ||
NestedField::optional(3, "baz", Type::Primitive(PrimitiveType::Boolean)).into(), | ||
]) | ||
.with_schema_id(1) | ||
.with_identifier_field_ids(vec![2]) | ||
.build() | ||
.unwrap(); | ||
|
||
// Create table | ||
let table_creation = TableCreation::builder() | ||
.name(table_id.name.clone()) | ||
.schema(table_schema.clone()) | ||
.properties(HashMap::from([("owner".to_string(), "testx".to_string())])) | ||
.build(); | ||
|
||
let table = catalog | ||
.create_table(&table_id.namespace, table_creation) | ||
.await | ||
.unwrap(); | ||
|
||
println!("Table created: {:?}", table.metadata()); | ||
// ANCHOR_END: create_table | ||
|
||
// ANCHOR: load_table | ||
let table2 = catalog | ||
.load_table(&TableIdent::from_strs(["default", "t2"]).unwrap()) | ||
.await | ||
.unwrap(); | ||
println!("{:?}", table2.metadata()); | ||
// ANCHOR_END: load_table | ||
} |
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,67 @@ | ||
# 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. | ||
|
||
[package] | ||
name = "iceberg" | ||
version = { workspace = true } | ||
edition = { workspace = true } | ||
rust-version = { workspace = true } | ||
|
||
categories = ["database"] | ||
description = "Apache Iceberg Rust implementation" | ||
repository = { workspace = true } | ||
license = { workspace = true } | ||
keywords = ["iceberg"] | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
apache-avro = { workspace = true } | ||
arrow-arith = { workspace = true } | ||
arrow-array = { workspace = true } | ||
arrow-schema = { workspace = true } | ||
async-trait = { workspace = true } | ||
bimap = { workspace = true } | ||
bitvec = { workspace = true } | ||
chrono = { workspace = true } | ||
derive_builder = { workspace = true } | ||
either = { workspace = true } | ||
futures = { workspace = true } | ||
itertools = { workspace = true } | ||
lazy_static = { workspace = true } | ||
log = { workspace = true } | ||
murmur3 = { workspace = true } | ||
once_cell = { workspace = true } | ||
opendal = { workspace = true } | ||
ordered-float = { workspace = true } | ||
reqwest = { workspace = true } | ||
rust_decimal = { workspace = true } | ||
serde = { workspace = true } | ||
serde_bytes = { workspace = true } | ||
serde_derive = { workspace = true } | ||
serde_json = { workspace = true } | ||
serde_repr = { workspace = true } | ||
serde_with = { workspace = true } | ||
typed-builder = { workspace = true } | ||
url = { workspace = true } | ||
urlencoding = { workspace = true } | ||
uuid = { workspace = true } | ||
|
||
[dev-dependencies] | ||
pretty_assertions = { workspace = true } | ||
tempfile = { workspace = true } | ||
tera = { workspace = true } | ||
tokio = { workspace = true } |
Oops, something went wrong.