File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,27 @@ use datafusion::prelude::*;
5050
5151Here is a minimal example showing the execution of a query using the DataFrame API.
5252
53+ Create DataFrame using macro API from in memory rows
54+
55+ ``` rust
56+ use datafusion :: prelude :: * ;
57+ use datafusion :: error :: Result ;
58+
59+ #[tokio:: main]
60+ async fn main () -> Result <()> {
61+ // Create a new dataframe with in-memory data using macro
62+ let df = dataframe! (
63+ " a" => [1 , 2 , 3 ],
64+ " b" => [true , true , false ],
65+ " c" => [Some (" foo" ), Some (" bar" ), None ]
66+ )? ;
67+ df . show (). await ? ;
68+ Ok (())
69+ }
70+ ```
71+
72+ Create DataFrame from file or in memory rows using standard API
73+
5374``` rust
5475use datafusion :: arrow :: array :: {Int32Array , RecordBatch , StringArray };
5576use datafusion :: arrow :: datatypes :: {DataType , Field , Schema };
@@ -84,12 +105,6 @@ async fn main() -> Result<()> {
84105 let df = ctx . read_batch (batch )? ;
85106 df . show (). await ? ;
86107
87- // Create a new dataframe with in-memory data using macro
88- let df = dataframe! (
89- " id" => [1 , 2 , 3 ],
90- " name" => [" foo" , " bar" , " baz" ]
91- )? ;
92- df . show (). await ? ;
93108 Ok (())
94109}
95110```
You can’t perform that action at this time.
0 commit comments