YjyJeff commented on code in PR #9592:
URL: https://github.com/apache/arrow-datafusion/pull/9592#discussion_r1523018799


##########
datafusion/sql/src/select.rs:
##########
@@ -276,33 +277,59 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         Ok(plan)
     }
 
-    // Try converting Expr::Unnest to LogicalPlan::Unnest if possible, 
otherwise do the final projection
+    /// Try converting Expr(Unnest(Expr)) to Projection/Unnest/Projection
     pub(super) fn try_process_unnest(
         &self,
         input: LogicalPlan,
         select_exprs: Vec<Expr>,
     ) -> Result<LogicalPlan> {
         let mut unnest_columns = vec![];
-        // Map unnest expressions to their argument
-        let projection_exprs = select_exprs
+        let mut inner_projection_exprs = vec![];
+
+        let outer_projection_exprs = select_exprs
             .into_iter()
             .map(|expr| {
-                if let Expr::Unnest(Unnest { ref exprs }) = expr {
+                let Transformed {
+                    data: transformed_expr,
+                    transformed,
+                    tnr: _,
+                } = expr.transform_up_mut(&mut |expr: Expr| {

Review Comment:
   @jayzhan211 The transform is essential for this feature. We need to rewrite 
the expression in bottom-up recursion such that we can extract the child and 
parent expression of the unnest function. The reason to split out the Column 
variant is that: we need to retain the `relation` field



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to