From 9f4dc2443541dd5ed4bf6d7fef4dfa8ddf90f48c Mon Sep 17 00:00:00 2001 From: Jax Liu Date: Tue, 24 Dec 2024 23:29:11 +0800 Subject: [PATCH] chore: improve and fix the rest example --- crates/examples/src/rest_catalog_namespace.rs | 7 ++++++- crates/examples/src/rest_catalog_table.rs | 13 +++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/examples/src/rest_catalog_namespace.rs b/crates/examples/src/rest_catalog_namespace.rs index 0a508a7d8..99aaf2e64 100644 --- a/crates/examples/src/rest_catalog_namespace.rs +++ b/crates/examples/src/rest_catalog_namespace.rs @@ -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); diff --git a/crates/examples/src/rest_catalog_table.rs b/crates/examples/src/rest_catalog_table.rs index a0a672f15..17455915f 100644 --- a/crates/examples/src/rest_catalog_table.rs +++ b/crates/examples/src/rest_catalog_table.rs @@ -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); @@ -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 }