(&self, args: &[Expr])
| 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 { |
no test coverage detected