Dandandan commented on a change in pull request #9645: URL: https://github.com/apache/arrow/pull/9645#discussion_r593884833
########## File path: rust/datafusion/examples/flight_server.rs ########## @@ -94,28 +94,26 @@ impl FlightService for FlightServiceImpl { "alltypes_plain", &format!("{}/alltypes_plain.parquet", testdata), ) - .map_err(|e| to_tonic_err(&e))?; + .map_err(to_tonic_err)?; - // create the query plan - let plan = ctx - .create_logical_plan(&sql) - .and_then(|plan| ctx.optimize(&plan)) - .and_then(|plan| ctx.create_physical_plan(&plan)) - .map_err(|e| to_tonic_err(&e))?; + // create the DataFrame + let df = ctx.sql(sql).map_err(to_tonic_err)?; // execute the query - let results = - collect(plan.clone()).await.map_err(|e| to_tonic_err(&e))?; + let results = df.collect().await.map_err(to_tonic_err)?; if results.is_empty() { return Err(Status::internal("There were no results from ticket")); } + let physical_plan = ctx Review comment: I "discovered" you can make a `DFSchema` an arrow `Schema` again with `df.schema().clone().into()` which I think is maybe even better? The approach to use `batches[0]` here doesn't work as the batches have type `Result<FlightData, Status>`, so that would probable need some more "extraction" to retrieve the schema. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org