alamb commented on a change in pull request #9645: URL: https://github.com/apache/arrow/pull/9645#discussion_r593885249
########## File path: rust/datafusion/examples/flight_server.rs ########## @@ -94,28 +94,22 @@ 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")); } // add an initial FlightData message that sends schema let options = arrow::ipc::writer::IpcWriteOptions::default(); - let schema = plan.schema(); let schema_flight_data = arrow_flight::utils::flight_data_from_arrow_schema( - schema.as_ref(), + &df.schema().clone().into(), Review comment: ❤️ -- looks great @Dandandan ---------------------------------------------------------------- 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