mustafasrepo commented on code in PR #7917:
URL: https://github.com/apache/arrow-datafusion/pull/7917#discussion_r1369827482


##########
datafusion/physical-expr/src/equivalence.rs:
##########
@@ -885,6 +885,240 @@ fn req_satisfied(given: LexOrderingRef, req: 
&[PhysicalSortRequirement]) -> bool
     true
 }
 
+/// Combine equivalence properties of the given join inputs.
+pub fn combine_join_equivalence_properties(
+    join_type: JoinType,
+    left_properties: EquivalenceProperties,
+    right_properties: EquivalenceProperties,
+    left_columns_len: usize,
+    on: &[(Column, Column)],
+    schema: SchemaRef,
+) -> EquivalenceProperties {
+    let mut new_properties = EquivalenceProperties::new(schema);
+    match join_type {
+        JoinType::Inner | JoinType::Left | JoinType::Full | JoinType::Right => 
{
+            new_properties.extend(left_properties.classes().to_vec());
+            let new_right_properties = right_properties
+                .classes()
+                .iter()
+                .map(|prop| {
+                    let new_head = Column::new(
+                        prop.head().name(),
+                        left_columns_len + prop.head().index(),
+                    );
+                    let new_others = prop
+                        .others()
+                        .iter()
+                        .map(|col| {
+                            Column::new(col.name(), left_columns_len + 
col.index())
+                        })
+                        .collect::<Vec<_>>();
+                    EquivalentClass::new(new_head, new_others)
+                })
+                .collect::<Vec<_>>();
+
+            new_properties.extend(new_right_properties);
+        }
+        JoinType::LeftSemi | JoinType::LeftAnti => {
+            new_properties.extend(left_properties.classes().to_vec())
+        }
+        JoinType::RightSemi | JoinType::RightAnti => {
+            new_properties.extend(right_properties.classes().to_vec())
+        }
+    }
+
+    if join_type == JoinType::Inner {
+        on.iter().for_each(|(column1, column2)| {
+            let new_column2 =
+                Column::new(column2.name(), left_columns_len + 
column2.index());
+            new_properties.add_equal_conditions((column1, &new_column2))
+        })
+    }
+    new_properties
+}
+
+/// Calculate equivalence properties for the given cross join operation.
+pub fn cross_join_equivalence_properties(

Review Comment:
   This function is copy-pasted



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