holicc commented on issue #4850:
URL: 
https://github.com/apache/arrow-datafusion/issues/4850#issuecomment-1718676317

   IMHO, `TableFunction` is essentially a `TableProvider`. Therefore, we can 
make a new trait that returns a `TableProvider` and execute the table function 
in 
[`create_relation`](https://github.com/apache/arrow-datafusion/blob/cde74016e930ffd9c55eed403b84bcd026f38d0f/datafusion/sql/src/relation/mod.rs#L27)
 and using `TableScan` to build a `LogicPlan`
   
   Add a new trait:
   
   ```rust
   #[async_trait]
   pub trait TableFunction: Sync + Send {
       async fn execute(
           &self,
           table: impl Into<OwnedTableReference>,
           state: &SessionState,
       ) -> Result<Arc<dyn TableProvider>>;
   }
   ```
   
   add new method to `FunctionRegistry`
   
   ```rust
   pub trait FunctionRegistry {
       ...
       /// Returns a reference to the table function named `name`.
       fn table_function(&self, name: &str) -> Result<Arc<dyn TableFunction>>;
   }
   ```


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