dharanad commented on code in PR #11273: URL: https://github.com/apache/datafusion/pull/11273#discussion_r1667772206
########## datafusion/sql/src/expr/mod.rs: ########## @@ -629,6 +630,36 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { } } + /// Parses a struct(..) expression and plans it creation + fn parse_struct( + &self, + schema: &DFSchema, + planner_context: &mut PlannerContext, + values: Vec<sqlparser::ast::Expr>, + fields: Vec<StructField>, + ) -> Result<Expr> { + if !fields.is_empty() { + return not_impl_err!("Struct fields are not supported yet"); + } + let is_named_struct = values + .iter() + .any(|value| matches!(value, SQLExpr::Named { .. })); + + let mut create_struct_args = if is_named_struct { + self.create_named_struct_expr(values, schema, planner_context)? + } else { + self.create_struct_expr(values, schema, planner_context)? + }; + + for planner in self.planners.iter() { + match planner.plan_struct_literal(create_struct_args, is_named_struct)? { + PlannerResult::Planned(expr) => return Ok(expr), + PlannerResult::Original(args) => create_struct_args = args, + } + } Review Comment: Based on my understanding we also have a `named_struct` function which is an alias for `struct` function with input expressions **optionally named**. In this PR i am not moving `named_struct` function to udp. My understanding was to move `create_named_struct` & `create_struct` which were solely handling `struct` function. -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org