asubiotto commented on code in PR #16985:
URL: https://github.com/apache/datafusion/pull/16985#discussion_r2250831837


##########
datafusion/physical-plan/src/unnest.rs:
##########
@@ -99,10 +105,38 @@ impl UnnestExec {
     /// This function creates the cache object that stores the plan properties 
such as schema, equivalence properties, ordering, partitioning, etc.
     fn compute_properties(
         input: &Arc<dyn ExecutionPlan>,
+        list_column_indices: &[ListUnnest],
+        struct_column_indices: &[usize],
         schema: SchemaRef,
     ) -> PlanProperties {
+        let list_column_indices: Vec<usize> = list_column_indices
+            .iter()
+            .map(|list_unnest| list_unnest.index_in_input_schema)
+            .collect();
+        let non_unnested_indices: Vec<usize> = input
+            .schema()
+            .fields()
+            .iter()
+            .enumerate()
+            .filter(|(idx, _)| {
+                !list_column_indices.contains(idx) && 
!struct_column_indices.contains(idx)
+            })
+            .map(|(idx, _)| idx)
+            .collect();
+
+        // Create the unnest equivalence properties by copying the input 
plan's equivalence properties
+        // for the unaffected columns.
+        // Except for the constraints, which are removed entirely because the 
unnest operation invalidates
+        // any global uniqueness or primary-key constraints.
+        let input_eq_properties = input.equivalence_properties();
+        let projection_mapping =
+            ProjectionMapping::from_indices(&non_unnested_indices, 
&schema).unwrap();
+        let eq_properties = input_eq_properties
+            .project(&projection_mapping, schema.clone())
+            // Remove any existing constraints

Review Comment:
   nit: remove this comment, I think you were clear enough above.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to