jayzhan211 commented on code in PR #26433:
URL: https://github.com/apache/datafusion/pull/26433#discussion_r4313644604


##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -678,6 +679,24 @@ impl ExprSchemable for Expr {
             Expr::LambdaVariable(LambdaVariable {
                 field: Some(field), ..
             }) => Ok(Arc::clone(field).renamed(&schema_name)),
+            Expr::Unnest(Unnest { expr, .. }) => {

Review Comment:
   nit: since depth is always 1 here, matching the list variants directly 
avoids the `is_list()` + helper round trip:
   
   ```diff
                Expr::Unnest(Unnest { expr, .. }) => {
   -                let data_type = expr.get_type(schema)?;
                    let nullable = self.nullable(schema)?;
   -                if data_type.is_list() {
   -                    Ok(Arc::new(
   -                        utils::get_unnested_list_field(&data_type, 1)?
   -                            .clone()
   -                            .with_name(&schema_name)
   -                            .with_nullable(nullable),
   -                    ))
   -                } else {
   -                    Ok(Arc::new(Field::new(
   +                match expr.get_type(schema)? {
   +                    DataType::List(field)
   +                    | DataType::LargeList(field)
   +                    | DataType::FixedSizeList(field, _)
   +                    | DataType::ListView(field)
   +                    | DataType::LargeListView(field) => Ok(Arc::new(
   +                        field
   +                            .as_ref()
   +                            .clone()
   +                            .with_name(&schema_name)
   +                            .with_nullable(nullable),
   +                    )),
   +                    _ => Ok(Arc::new(Field::new(
                            &schema_name,
                            self.get_type(schema)?,
                            nullable,
   -                    )))
   +                    ))),
                    }
                }
   ```
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to