comphead commented on code in PR #194:
URL: 
https://github.com/apache/arrow-datafusion-comet/pull/194#discussion_r1526528820


##########
core/src/execution/datafusion/planner.rs:
##########
@@ -858,6 +862,133 @@ impl PhysicalPlanner {
                     Arc::new(CometExpandExec::new(projections, child, schema)),
                 ))
             }
+            OpStruct::HashJoin(join) => {
+                assert!(children.len() == 2);
+                let (mut left_scans, left) = self.create_plan(&children[0], 
inputs)?;
+                let (mut right_scans, right) = self.create_plan(&children[1], 
inputs)?;
+
+                left_scans.append(&mut right_scans);
+
+                let left_join_exprs: Vec<_> = join
+                    .left_join_keys
+                    .iter()
+                    .map(|expr| self.create_expr(expr, left.schema()))
+                    .collect::<Result<Vec<_>, _>>()?;
+                let right_join_exprs: Vec<_> = join
+                    .right_join_keys
+                    .iter()
+                    .map(|expr| self.create_expr(expr, right.schema()))
+                    .collect::<Result<Vec<_>, _>>()?;
+
+                let join_on = left_join_exprs
+                    .into_iter()
+                    .zip(right_join_exprs)
+                    .collect::<Vec<_>>();
+
+                let join_type = match join.join_type.try_into() {
+                    Ok(JoinType::Inner) => DFJoinType::Inner,
+                    Ok(JoinType::LeftOuter) => DFJoinType::Left,
+                    Ok(JoinType::RightOuter) => DFJoinType::Right,
+                    Ok(JoinType::FullOuter) => DFJoinType::Full,
+                    Ok(JoinType::LeftSemi) => DFJoinType::LeftSemi,
+                    Ok(JoinType::RightSemi) => DFJoinType::RightSemi,
+                    Ok(JoinType::LeftAnti) => DFJoinType::LeftAnti,
+                    Ok(JoinType::RightAnti) => DFJoinType::RightAnti,
+                    Err(_) => {
+                        return Err(ExecutionError::GeneralError(format!(
+                            "Unsupported join type: {:?}",
+                            join.join_type
+                        )));
+                    }
+                };
+
+                // Handle join filter as DataFusion `JoinFilter` struct
+                let join_filter = if let Some(expr) = &join.condition {
+                    let left_schema = left.schema();
+                    let right_schema = right.schema();
+                    let left_fields = left_schema.fields();
+                    let right_fields = right_schema.fields();
+                    let all_fields: Vec<_> = left_fields
+                        .into_iter()
+                        .chain(right_fields)
+                        .cloned()
+                        .collect();
+                    let full_schema = Arc::new(Schema::new(all_fields));
+
+                    let physical_expr = self.create_expr(expr, full_schema)?;
+                    let (left_field_indices, right_field_indices) = 
expr_to_columns(
+                        &physical_expr,
+                        left.schema().fields.len(),

Review Comment:
   ```suggestion
                           left.schema().fields.len(),
                           left_fields.len(),
   ```



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