chenkovsky commented on code in PR #16610:
URL: https://github.com/apache/datafusion/pull/16610#discussion_r2177627341


##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -617,31 +617,55 @@ impl Unparser<'_> {
     }
 
     fn get_field_to_sql(&self, args: &[Expr]) -> Result<ast::Expr> {
-        if args.len() != 2 {
-            return internal_err!("get_field must have exactly 2 arguments");
-        }
-
-        let mut id = match &args[0] {
-            Expr::Column(col) => match self.col_to_sql(col)? {
-                ast::Expr::Identifier(ident) => vec![ident],
-                ast::Expr::CompoundIdentifier(idents) => idents,
-                other => return internal_err!("expected col_to_sql to return 
an Identifier or CompoundIdentifier, but received: {:?}", other),
-            },
-            _ => return internal_err!("get_field expects first argument to be 
column, but received: {:?}", &args[0]),
-        };
-
-        let field = match &args[1] {
-            Expr::Literal(lit, _) => 
self.new_ident_quoted_if_needs(lit.to_string()),
+        match &args[0] {
+            Expr::Column(col) => {
+                let mut id = match self.col_to_sql(col)? {
+                    ast::Expr::Identifier(ident) => vec![ident],
+                    ast::Expr::CompoundIdentifier(idents) => idents,
+                    other => return internal_err!("expected col_to_sql to 
return an Identifier or CompoundIdentifier, but received: {:?}", other),
+                };
+                for arg in args.iter().skip(1) {
+                    let field = match arg {
+                        Expr::Literal(lit, _) => 
self.new_ident_quoted_if_needs(lit.to_string()),
+                        _ => {
+                            return internal_err!(
+                                "get_field expects arguments except the first 
one to be a string, but received: {:?}",
+                                &arg
+                            )
+                        }
+                    };
+                    id.push(field);
+                }

Review Comment:
   updated



-- 
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

Reply via email to