From 10949e5e36a20150457b6451b9b4622daa819f7a Mon Sep 17 00:00:00 2001 From: Abdullahsab3 Date: Sat, 4 Jan 2025 15:34:55 +0100 Subject: [PATCH] docs: querying a table Signed-off-by: Abdullahsab3 --- docs/usage/querying-delta-tables.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/usage/querying-delta-tables.md b/docs/usage/querying-delta-tables.md index 0d693e0f5a..848f005ba4 100644 --- a/docs/usage/querying-delta-tables.md +++ b/docs/usage/querying-delta-tables.md @@ -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?; ``` \ No newline at end of file