jayzhan211 commented on code in PR #11273: URL: https://github.com/apache/datafusion/pull/11273#discussion_r1666732504
########## datafusion/sql/src/expr/mod.rs: ########## @@ -629,6 +630,41 @@ 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() { + let result = if is_named_struct { + planner.plan_create_named_struct(create_struct_args)? + } else { + planner.plan_create_struct(create_struct_args)? Review Comment: Can we have one StructPlan that returns `struct` or `named_struct` based on the values? ```rust 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)? }; ``` The logic here should be inside planner -- 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