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

chore: improve and fix the rest example #842

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/examples/src/rest_catalog_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ use std::collections::HashMap;
use iceberg::{Catalog, NamespaceIdent};
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};

/// It a simple example that demonstrates how to create a namespace in a REST catalog.
/// It requires a running instance of the iceberg-rest catalog for the port 8181.
/// You can find how to run the iceberg-rest catalog in the official documentation.
///
/// [Quickstart](https://iceberg.apache.org/spark-quickstart/)
#[tokio::main]
async fn main() {
// ANCHOR: create_catalog
// Create catalog
let config = RestCatalogConfig::builder()
.uri("http://localhost:8080".to_string())
.uri("http://localhost:8181".to_string())
.build();

let catalog = RestCatalog::new(config);
Expand Down
13 changes: 9 additions & 4 deletions crates/examples/src/rest_catalog_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
use iceberg::{Catalog, TableCreation, TableIdent};
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};

/// This is a simple example that demonstrates how to create a table in a REST catalog and get it back.
/// It requires a running instance of the iceberg-rest catalog for the port 8080.
/// You can find how to run the iceberg-rest catalog in the official documentation.
///
/// [Quickstart](https://iceberg.apache.org/spark-quickstart/)
#[tokio::main]
async fn main() {
// Create catalog
let config = RestCatalogConfig::builder()
.uri("http://localhost:8080".to_string())
.uri("http://localhost:8181".to_string())
.build();

let catalog = RestCatalog::new(config);
Expand Down Expand Up @@ -60,10 +65,10 @@ async fn main() {
// ANCHOR_END: create_table

// ANCHOR: load_table
let table2 = catalog
.load_table(&TableIdent::from_strs(["default", "t2"]).unwrap())
let table_created = catalog
.load_table(&TableIdent::from_strs(["default", "t1"]).unwrap())
.await
.unwrap();
println!("{:?}", table2.metadata());
println!("{:?}", table_created.metadata());
// ANCHOR_END: load_table
}
Loading