File tree Expand file tree Collapse file tree
datafusion/sql/src/relation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,6 +154,35 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
154154 "UNNEST table factor with offset is not supported yet"
155155 ) ;
156156 }
157+ TableFactor :: Function {
158+ name, args, alias, ..
159+ } => {
160+ let tbl_func_ref = self . object_name_to_table_reference ( name) ?;
161+ let schema = planner_context
162+ . outer_query_schema ( )
163+ . cloned ( )
164+ . unwrap_or_else ( DFSchema :: empty) ;
165+ let func_args = args
166+ . into_iter ( )
167+ . map ( |arg| match arg {
168+ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( expr) )
169+ | FunctionArg :: Named {
170+ arg : FunctionArgExpr :: Expr ( expr) ,
171+ ..
172+ } => {
173+ self . sql_expr_to_logical_expr ( expr, & schema, planner_context)
174+ }
175+ _ => plan_err ! ( "Unsupported function argument: {arg:?}" ) ,
176+ } )
177+ . collect :: < Result < Vec < Expr > > > ( ) ?;
178+ let provider = self
179+ . context_provider
180+ . get_table_function_source ( tbl_func_ref. table ( ) , func_args) ?;
181+ let plan =
182+ LogicalPlanBuilder :: scan ( tbl_func_ref. table ( ) , provider, None ) ?
183+ . build ( ) ?;
184+ ( plan, alias)
185+ }
157186 // @todo Support TableFactory::TableFunction?
158187 _ => {
159188 return not_impl_err ! (
You can’t perform that action at this time.
0 commit comments