Skip to content

Commit 5400bbe

Browse files
authored
chore: improve and fix the rest example (#842)
1 parent f33628e commit 5400bbe

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

crates/examples/src/rest_catalog_namespace.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ use std::collections::HashMap;
2020
use iceberg::{Catalog, NamespaceIdent};
2121
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
2222

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

3136
let catalog = RestCatalog::new(config);

crates/examples/src/rest_catalog_table.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
2121
use iceberg::{Catalog, TableCreation, TableIdent};
2222
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
2323

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

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

6267
// ANCHOR: load_table
63-
let table2 = catalog
64-
.load_table(&TableIdent::from_strs(["default", "t2"]).unwrap())
68+
let table_created = catalog
69+
.load_table(&TableIdent::from_strs(["default", "t1"]).unwrap())
6570
.await
6671
.unwrap();
67-
println!("{:?}", table2.metadata());
72+
println!("{:?}", table_created.metadata());
6873
// ANCHOR_END: load_table
6974
}

0 commit comments

Comments
 (0)