andygrove commented on code in PR #2836:
URL: https://github.com/apache/datafusion-comet/pull/2836#discussion_r2590642813
##########
native/core/src/execution/planner.rs:
##########
@@ -1528,6 +1530,107 @@ impl PhysicalPlanner {
Arc::new(SparkPlan::new(spark_plan.plan_id, expand,
vec![child])),
))
}
+ OpStruct::Explode(explode) => {
+ assert_eq!(children.len(), 1);
+ let (scans, child) = self.create_plan(&children[0], inputs,
partition_count)?;
+
+ // Create the expression for the array to explode
+ let child_expr = if let Some(child_expr) = &explode.child {
+ self.create_expr(child_expr, child.schema())?
+ } else {
+ return Err(ExecutionError::GeneralError(
+ "Explode operator requires a child
expression".to_string(),
+ ));
+ };
+
+ // Create projection expressions for other columns
+ let projections: Vec<Arc<dyn PhysicalExpr>> = explode
+ .project_list
+ .iter()
+ .map(|expr| self.create_expr(expr, child.schema()))
+ .collect::<Result<Vec<_>, _>>()?;
+
+ // For UnnestExec, we need to add a projection to put the
columns in the right order:
+ // 1. First add all projection columns
+ // 2. Then add the array column to be exploded
+ // Then UnnestExec will unnest the last column
+
+ let mut project_exprs: Vec<(Arc<dyn PhysicalExpr>, String)> =
projections
+ .iter()
+ .enumerate()
+ .map(|(idx, expr)| (Arc::clone(expr),
format!("col_{idx}")))
+ .collect();
+
+ // Add the array column as the last column
+ let array_col_name = format!("col_{}", projections.len());
Review Comment:
I removed this now and preserve original names
--
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]