File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ using the [tpchgen](https://github.com/clflushopt/tpchgen-rs) crates.
1818The ` datafusion-tpch ` crate offers two possible ways to register the TPCH individual
1919table functions.
2020
21+ You can register functions individually.
22+
2123``` rust
2224#[tokio:: main]
2325async fn main () -> Result <()> {
@@ -43,3 +45,25 @@ async fn main() -> Result<()> {
4345}
4446```
4547
48+ Or use the helper function ` register_tpch_udtfs ` to register all of them
49+ at once (which is the preferred approach).
50+
51+ ``` rust
52+ use datafusion_tpch :: register_tpch_udtfs;
53+
54+ #[tokio:: main]
55+ async fn main () -> Result <()> {
56+ // create local execution context
57+ let ctx = SessionContext :: new ();
58+
59+ // Register all the UDTFs.
60+ register_tpch_udtfs (& ctx );
61+
62+ // Generate the nation table with a scale factor of 1.
63+ let df = ctx
64+ . sql (format! (" SELECT * FROM tpch_nation(1.0);" ). as_str ())
65+ . await ? ;
66+ df . show (). await ? ;
67+ Ok (())
68+ }
69+ ```
You can’t perform that action at this time.
0 commit comments