Skip to content

Commit

Permalink
move sample to a separate repo
Browse files Browse the repository at this point in the history
  • Loading branch information
r3stl355 committed Sep 3, 2022
1 parent 926f17b commit 67548b0
Showing 1 changed file with 1 addition and 49 deletions.
50 changes: 1 addition & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,7 @@ This is a simple library for Rust to access data published via Delta Sharing

## Sample use

1. Create a new Rust binary package, e.g. `cargo new delta_sharing_test --bin`

2. Add the following dependencies to `Cargo.toml`

```
delta-sharing = { git = "https://github.com/r3stl355/delta-sharing-rust-client" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.9"
```

3. Add a file named `config.json` in the `src` folder next to the `main.rs` file with the following content (replace values within <> with your Delta Share details)
```
{
"shareCredentialsVersion":1,
"bearerToken":"<your Delta Share access token>",
"endpoint":"<your Delta Share endpoinit URL>"
}
```

4. Replace the `main` function with
```
fn main() {
use std::{fs};
env_logger::init();
let conf_str = &fs::read_to_string("./config.json").unwrap();
let config: delta_sharing::protocol::ProviderConfig = serde_json::from_str(conf_str).expect("Invalid configuration");
let mut app = delta_sharing::application::Application::new(config, None).unwrap();
let shares = app.list_shares().unwrap();
if shares.len() == 0 {
println!("At least 1 Delta Share is required");
} else {
let tables = app.list_all_tables(&shares[0]).unwrap();
if shares.len() == 0 {
println!("You need to have at least one table in share {}, or use a different share", shares[0].name);
} else {
let res = app.get_dataframe(&tables[0]).unwrap().collect().unwrap();
println!("Dataframe:\n {}", res);
}
}
}
```

5. Run, e.g. `cargo run main` (alternatively, you can use `RUST_LOG=debug cargo run main` if you want to see some extra debugging information)
Use this [sample project](https://github.com/r3stl355/delta-sharing-rust-cllient-use-example) for a quick start

## TODO

Expand Down

0 comments on commit 67548b0

Please sign in to comment.