MCPcopy Create free account
hub / github.com/apache/datafusion / named_struct_to_sql

Method named_struct_to_sql

datafusion/sql/src/unparser/expr.rs:698–720  ·  view source on GitHub ↗
(&self, args: &[Expr])

Source from the content-addressed store, hash-verified

696 }
697
698 fn named_struct_to_sql(&self, args: &[Expr]) -> Result<ast::Expr> {
699 assert_or_internal_err!(
700 args.len().is_multiple_of(2),
701 "named_struct must have an even number of arguments"
702 );
703
704 let args = args
705 .chunks_exact(2)
706 .map(|chunk| {
707 let key = match &chunk[0] {
708 Expr::Literal(ScalarValue::Utf8(Some(s)), _) => self.new_ident_quoted_if_needs(s.to_string()),
709 _ => return internal_err!("named_struct expects even arguments to be strings, but received: {:?}", &chunk[0])
710 };
711
712 Ok(ast::DictionaryField {
713 key,
714 value: Box::new(self.expr_to_sql(&chunk[1])?),
715 })
716 })
717 .collect::<Result<Vec<_>>>()?;
718
719 Ok(ast::Expr::Dictionary(args))
720 }
721
722 fn get_field_to_sql(&self, args: &[Expr]) -> Result<ast::Expr> {
723 if args.len() < 2 {

Callers 1

Calls 6

newFunction · 0.85
expr_to_sqlMethod · 0.80
DictionaryClass · 0.50
mapMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected