bubulalabu commented on code in PR #18224: URL: https://github.com/apache/datafusion/pull/18224#discussion_r2456545539
########## datafusion/core/src/execution/lateral_table_function.rs: ########## @@ -0,0 +1,450 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Execution plan for LATERAL table functions + +use std::any::Any; +use std::fmt; +use std::pin::Pin; +use std::sync::Arc; +use std::task::{Context, Poll}; + +use arrow::array::ArrayRef; +use arrow::compute::concat_batches; +use arrow::datatypes::SchemaRef; +use arrow::record_batch::RecordBatch; +use datafusion_catalog::TableFunction; +use datafusion_common::{internal_err, Result, ScalarValue}; +use datafusion_execution::TaskContext; +use datafusion_expr::{ColumnarValue, Expr}; +use datafusion_physical_expr::{EquivalenceProperties, PhysicalExpr}; +use datafusion_physical_plan::{ + DisplayAs, DisplayFormatType, ExecutionPlan, ExecutionPlanProperties, PlanProperties, + RecordBatchStream, SendableRecordBatchStream, +}; +use futures::future::BoxFuture; +use futures::stream::Stream; +use futures::{ready, FutureExt, StreamExt}; + +use crate::execution::session_state::SessionState; + +/// Execution plan for LATERAL table functions Review Comment: No, it doesn't. DuckDB uses generic correlated query unnesting and batched table functions. We can do the same specially for table functions. But for that we need something like `create_plan` as described in the above comment. The implementation in this PR is suboptimal. It's just the best I can come up with without extending the public API. If the extension of the public API is an option, I'd ideally go with the new `StreamingTableFunctionImpl` trait and have an internal adapter that bridges current TableFunction implementations to adhere to `StreamingTableFunctionImpl`. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
