-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtpchgen.rs
More file actions
39 lines (28 loc) · 1.3 KB
/
tpchgen.rs
File metadata and controls
39 lines (28 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Example of using the datafusion-tpch extension to generate TPCH datasets
//! on the the fly in datafusion.
use datafusion::prelude::{SessionConfig, SessionContext};
use datafusion_tpch::register_tpch_udtf;
#[tokio::main]
async fn main() -> datafusion::error::Result<()> {
let ctx = SessionContext::new_with_config(SessionConfig::new().with_information_schema(true));
register_tpch_udtf(&ctx);
let sql_df = ctx.sql(&format!("SELECT * FROM tpch(1.0);")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SHOW TABLES;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM nation LIMIT 5;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM partsupp LIMIT 5;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM region LIMIT 5;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM customer LIMIT 5;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM orders LIMIT 5;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM lineitem LIMIT 5;")).await?;
sql_df.show().await?;
let sql_df = ctx.sql(&format!("SELECT * FROM part LIMIT 5;")).await?;
sql_df.show().await?;
Ok(())
}