xudong963 commented on a change in pull request #1183: URL: https://github.com/apache/arrow-datafusion/pull/1183#discussion_r738530404
########## File path: datafusion/src/execution/dataframe_impl.rs ########## @@ -56,8 +56,12 @@ impl DataFrameImpl { /// Create a physical plan async fn create_physical_plan(&self) -> Result<Arc<dyn ExecutionPlan>> { let state = self.ctx_state.lock().unwrap().clone(); + let has_optimized = state.has_optimized; Review comment: @houqp I don't mean `create_physical_plan` will be called twice. I mean https://github.com/apache/arrow-datafusion/blob/ad059a688fd8da7b360423e0d911f2f1f33dbb9f/datafusion/src/execution/context.rs#L613 will be called twice. Fox example ```rust #[tokio::main] async fn main() -> Result<()> { // create local execution context let mut ctx = ExecutionContext::new(); let testdata = datafusion::arrow::util::test_util::parquet_test_data(); // register parquet file with the execution context ctx.register_parquet( "alltypes_plain", &format!("{}/alltypes_plain.parquet", testdata), ) .await?; // execute the query let df = ctx .sql( "SELECT int_col, double_col, CAST(date_string_col as VARCHAR) \ FROM alltypes_plain \ WHERE id > 1 AND tinyint_col < double_col", ) .await?; // print the results df.show().await?; Ok(()) } ``` `ctx.sql(..)` and `df.show()` both will call logical plan optimization. Let me know where I misunderstand. cc @alamb -- 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. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org