Skip to content

Commit

Permalink
docs: querying a table
Browse files Browse the repository at this point in the history
Signed-off-by: Abdullahsab3 <[email protected]>
  • Loading branch information
Abdullahsab3 committed Jan 4, 2025
1 parent fc5c85e commit 10949e5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/usage/querying-delta-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,23 @@ Dask Name: read-parquet, 6 tasks
0 5 2021 12 4
0 6 2021 12 20
1 7 2021 12 20
```

When working with the Rust API, Apache Datafusion can be used to query data from a delta table.

```rust
let table = deltalake::open_table("../rust/tests/data/delta-0.8.0-partitioned").await?;
let ctx = SessionContext::new();
ctx.register_table("simple_table", Arc::new(table.clone()))?;
let df = ctx.sql("SELECT value FROM simple_table WHERE year = 2021").await?;
df.show().await?;
```

Apache Datafusion also supports a Dataframe interface than can be used instead of the SQL interface:
```rust
let table = deltalake::open_table("../rust/tests/data/delta-0.8.0-partitioned").await?;
let ctx = SessionContext::new();
let dataframe = ctx.read_table( Arc::new(table.clone()))?;
let df = dataframe.filter(col("year").eq(lit(2021)))?.select(vec![col("value")])?;
df.show().await?;
```

0 comments on commit 10949e5

Please sign in to comment.