query_example/
query_example.rs1use std::path::PathBuf;
2
3use azof_datafusion::context::ExecutionContext;
4
5#[tokio::main]
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let mut workspace_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
8 workspace_dir.pop();
9 workspace_dir.pop();
10
11 let test_data_path = workspace_dir.join("test-data");
12
13 let absolute_path = test_data_path.canonicalize()?;
14
15 let path_str = absolute_path.to_string_lossy().to_string();
16
17 let ctx = ExecutionContext::new(path_str);
18
19 let df = ctx
20 .sql(
21 "
22 SELECT key as symbol, revenue, net_income
23 FROM financials
24 AT ('2019-01-17T00:00:00.000Z') -- as per Financial Quarter end date
25 WHERE industry IN ('Software')
26 ORDER BY revenue DESC
27 LIMIT 5;
28 ",
29 )
30 .await?;
31
32 df.show().await?;
33
34 Ok(())
35}