Jesse-Bakker commented on code in PR #8306:
URL: https://github.com/apache/arrow-datafusion/pull/8306#discussion_r1407780600


##########
datafusion/core/src/datasource/function.rs:
##########
@@ -0,0 +1,56 @@
+// 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.
+
+//! A table that uses a function to generate data
+
+use super::TableProvider;
+
+use datafusion_common::Result;
+use datafusion_expr::Expr;
+
+use std::sync::Arc;
+
+/// A trait for table function implementations
+pub trait TableFunctionImpl: Sync + Send {
+    /// Create a table provider
+    fn call(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>>;

Review Comment:
   One specific use case for table-valued arguments to table-valued functions 
is, for example [windowing tvf's like in apache 
flink](https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/queries/window-agg/).
   
   Example which cannot be expressed by taking `Expr` arguments (maybe if 
`Expr::Row()` is added?):
   ```sql
   SELECT window_start, window_end, SUM(price)
     FROM TABLE(
       TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
     GROUP BY window_start, window_end;
   ```
   
   That can also be emulated, however, using something like:
   ```sql
   SELECT window_start, window_end, SUM(price)
     FROM Bid,
       TUMBLE(Bid.bidtime, INTERVAL '10' MINUTES))
       GROUP BY window_start, window_end;
   ```
   which doesn't need table-valued arguments (but does need to resolve 
`Expr::Column(name=bidtime)`. I'm not sure if the current API can do that?)



-- 
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]

Reply via email to