Skip to content

Apache DataFusion SQL Query Engine

doc: Move `dataframe!` example into dedicated example (#16197)

Oleks Vaaae4d7cbf0b
diff --git a/docs/source/user-guide/dataframe.md b/docs/source/user-guide/dataframe.md
index ef67bdeb0d..82f1eeb282 100644
--- a/docs/source/user-guide/dataframe.md
+++ b/docs/source/user-guide/dataframe.md
@@ -50,6 +50,27 @@ use datafusion::prelude::*;
Here is a minimal example showing the execution of a query using the DataFrame API.
+Create DataFrame using macro API from in memory rows
+
+```rust
+use datafusion::prelude::*;
+use datafusion::error::Result;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ // Create a new dataframe with in-memory data using macro
+ let df = dataframe!(
+ "a" => [1, 2, 3],
+ "b" => [true, true, false],
+ "c" => [Some("foo"), Some("bar"), None]
+ )?;
+ df.show().await?;
+ Ok(())
+}
+```
+
+Create DataFrame from file or in memory rows using standard API
+
```rust
use datafusion::arrow::array::{Int32Array, RecordBatch, StringArray};
use datafusion::arrow::datatypes::{DataType, Field, Schema};
@@ -84,12 +105,6 @@ async fn main() -> Result<()> {
let df = ctx.read_batch(batch)?;
df.show().await?;
- // Create a new dataframe with in-memory data using macro
- let df = dataframe!(
- "id" => [1, 2, 3],
- "name" => ["foo", "bar", "baz"]
- )?;
- df.show().await?;
Ok(())
}
```