Skip to content

Commit 2a5a431

Browse files
alambxudong963
andauthored
Update documentation example for change in API (#1812)
* Update documentation example for change in API * Update docs/source/user-guide/example-usage.md * Update docs/source/user-guide/example-usage.md Co-authored-by: xudong.w <[email protected]> Co-authored-by: xudong.w <[email protected]>
1 parent 0a1eee0 commit 2a5a431

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

docs/source/user-guide/example-usage.md

+15-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919

2020
# Example Usage
2121

22-
Run a SQL query against data stored in a CSV:
22+
## Update `Cargo.toml`
23+
24+
Add the following to your `Cargo.toml` file:
25+
26+
```toml
27+
datafusion = "7.0.0"
28+
tokio = "1.0"
29+
```
30+
31+
## Run a SQL query against data stored in a CSV:
2332

2433
```rust
2534
use datafusion::prelude::*;
@@ -28,18 +37,18 @@ use datafusion::prelude::*;
2837
async fn main() -> datafusion::error::Result<()> {
2938
// register the table
3039
let mut ctx = ExecutionContext::new();
31-
ctx.register_csv("example", "tests/example.csv", CsvReadOptions::new())?;
40+
ctx.register_csv("example", "tests/example.csv", CsvReadOptions::new()).await?;
3241

3342
// create a plan to run a SQL query
34-
let df = ctx.sql("SELECT a, MIN(b) FROM example GROUP BY a LIMIT 100")?;
43+
let df = ctx.sql("SELECT a, MIN(b) FROM example GROUP BY a LIMIT 100").await?;
3544

3645
// execute and print results
3746
df.show().await?;
3847
Ok(())
3948
}
4049
```
4150

42-
Use the DataFrame API to process data stored in a CSV:
51+
## Use the DataFrame API to process data stored in a CSV:
4352

4453
```rust
4554
use datafusion::prelude::*;
@@ -48,7 +57,7 @@ use datafusion::prelude::*;
4857
async fn main() -> datafusion::error::Result<()> {
4958
// create the dataframe
5059
let mut ctx = ExecutionContext::new();
51-
let df = ctx.read_csv("tests/example.csv", CsvReadOptions::new())?;
60+
let df = ctx.read_csv("tests/example.csv", CsvReadOptions::new()).await?;
5261

5362
let df = df.filter(col("a").lt_eq(col("b")))?
5463
.aggregate(vec![col("a")], vec![min(col("b"))])?;
@@ -59,7 +68,7 @@ async fn main() -> datafusion::error::Result<()> {
5968
}
6069
```
6170

62-
Both of these examples will produce
71+
## Output from both examples
6372

6473
```text
6574
+---+--------+

0 commit comments

Comments
 (0)