-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add the examples crate for rust
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
[package] | ||
name = "hudi-examples" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
rust-version.workspace = true | ||
keywords.workspace = true | ||
readme.workspace = true | ||
description.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
hudi = { path = "../hudi", features=["datafusion"] } | ||
|
||
[dev-dependencies] | ||
tokio = { workspace = true, features=["macros"] } | ||
datafusion = { workspace = true } | ||
|
||
[[example]] | ||
name = "hello" | ||
path = "hello.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
## Examples of how to use hudi-rs | ||
|
||
This directory contains a number of examples showcasing various capabilities of | ||
the `hudi` crate. | ||
|
||
All examples can be executed with: | ||
|
||
``` | ||
HUDI_DATA_PATH=/your/data cargo run --example $name | ||
``` | ||
|
||
A good starting point for the examples would be [`hello`](hello.rs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::sync::Arc; | ||
use std::env::var; | ||
|
||
use datafusion::{ | ||
error::Result, | ||
prelude::{DataFrame, SessionContext}, | ||
}; | ||
use hudi::HudiDataSource; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let data_path = var("HUDI_DATA_PATH").unwrap_or_else(|_| "/your/hudi/data/path".to_string()); | ||
|
||
let ctx = SessionContext::new(); | ||
let hudi = HudiDataSource::new(&data_path).await?; | ||
ctx.register_table("example", Arc::new(hudi))?; | ||
let df: DataFrame = ctx.sql("SELECT * FROM example").await?; | ||
df.show().await?; | ||
Ok(()) | ||
} |