Skip to content

Commit c867d2a

Browse files
committed
docs: add the examples crate for rust
1 parent f56603b commit c867d2a

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

crates/examples/Cargo.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[package]
19+
name = "hudi-examples"
20+
version.workspace = true
21+
edition.workspace = true
22+
license.workspace = true
23+
rust-version.workspace = true
24+
keywords.workspace = true
25+
readme.workspace = true
26+
description.workspace = true
27+
homepage.workspace = true
28+
repository.workspace = true
29+
30+
[dependencies]
31+
hudi = { path = "../hudi", features=["datafusion"] }
32+
33+
[dev-dependencies]
34+
tokio = { workspace = true, features=["full"] }
35+
datafusion = { workspace = true }
36+
37+
[[example]]
38+
name = "hello"
39+
path = "hello.rs"

crates/examples/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
-->
19+
20+
## Examples of how to use hudi-rs
21+
22+
This directory contains a number of examples showcasing various capabilities of
23+
the `hudi` crate.
24+
25+
All examples can be executed with:
26+
27+
```
28+
cargo run --example $name
29+
```
30+
31+
A good starting point for the examples would be [`hello`](hello.rs).

crates/examples/hello.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::sync::Arc;
2+
3+
use datafusion::{
4+
error::Result,
5+
prelude::{DataFrame, SessionContext},
6+
};
7+
use hudi::HudiDataSource;
8+
9+
#[tokio::main]
10+
async fn main() -> Result<()> {
11+
let data_path = "/your/hudi/data/path";
12+
13+
let ctx = SessionContext::new();
14+
let hudi = HudiDataSource::new(data_path).await?;
15+
ctx.register_table("example", Arc::new(hudi))?;
16+
let df: DataFrame = ctx.sql("SELECT * FROM example").await?;
17+
df.show().await?;
18+
Ok(())
19+
}

0 commit comments

Comments
 (0)