diff --git a/vortex-layout/src/plan/plans/struct_.rs b/vortex-layout/src/plan/plans/struct_.rs index ca375c4d4bf..b6635009a21 100644 --- a/vortex-layout/src/plan/plans/struct_.rs +++ b/vortex-layout/src/plan/plans/struct_.rs @@ -245,8 +245,7 @@ impl PlanParentReduceRule for ExpressionStructRule { .get(&ExactBoundExpr(expression.clone())) .vortex_expect("Bound expression missing free-field annotations") .clone(); - let expanded_root = expanded_struct_root(&child.dtype, fields)?; - let expanded = expand_struct_root(expression.clone(), &expanded_root, fields)?; + let expanded = expand_struct_root(expression.clone(), fields)?; let partitioned = partition_bound(expanded.clone(), make_bound_free_field_annotator(fields))?; if partitioned.partition_names.is_empty() { @@ -368,14 +367,13 @@ fn expanded_struct_root( fn expand_struct_root( expression: BoundExpression, - expanded_root: &BoundExpression, fields: &StructFields, ) -> VortexResult { Ok(expression .transform_down(|node| { if node.is_root() { return Ok(Transformed { - value: expanded_root.clone(), + value: expanded_struct_root(node.dtype(), fields)?, changed: true, order: TraversalOrder::Skip, }); @@ -392,28 +390,23 @@ fn expand_struct_root( return Ok(Transformed::no(node)); } - if let Some(field_name) = scalar_fn.as_opt::() { - let index = fields.find(field_name).ok_or_else(|| { - vortex_err!("Field {field_name} not found while expanding struct root") - })?; + if scalar_fn.is::() { return Ok(Transformed { - value: expanded_root.children()[index].clone(), - changed: true, + value: node, + changed: false, order: TraversalOrder::Skip, }); } if let Some(selection) = scalar_fn.as_opt::