SubhamSinghal commented on code in PR #27578:
URL: https://github.com/apache/datafusion/pull/27578#discussion_r4662441474


##########
datafusion/physical-plan/src/joins/piecewise_merge_join/exec.rs:
##########
@@ -406,6 +419,73 @@ impl PiecewiseMergeJoinExec {
         &self.sort_options
     }
 
+    /// The embedded projection, as indices into the unprojected join schema
+    pub fn projection(&self) -> Option<&ProjectionRef> {
+        self.projection.as_ref().map(|p| &p.indices)
+    }
+
+    /// Whether a parent projection has been embedded into this join.
+    pub fn contains_projection(&self) -> bool {
+        self.projection.is_some()
+    }
+
+    /// Returns a copy of this join whose output is `projection` of its 
current output.
+    ///
+    /// Only Inner/Left/Right/Full joins take one: the existence joins emit 
one side (plus
+    /// a `mark` column) through streams that do not narrow their input.
+    pub fn with_projection(&self, projection: Option<Vec<usize>>) -> 
Result<Self> {
+        let projection: Option<ProjectionRef> = projection.map(Into::into);
+        can_project(&self.schema, projection.as_deref())?;
+        let projection = combine_projections(projection.as_ref(), 
self.projection())?;
+
+        let join = Self::try_new(
+            Arc::clone(&self.buffered),
+            Arc::clone(&self.streamed),
+            self.on.clone(),
+            self.operator,
+            self.join_type,
+            self.num_partitions,
+        )?;
+        match projection {
+            Some(indices) => join.project(indices),
+            None => Ok(join),
+        }
+    }
+
+    /// Embeds `indices` into a join that has no projection yet.
+    fn project(mut self, indices: ProjectionRef) -> Result<Self> {
+        if !is_classic_join(self.join_type) {
+            return internal_err!(
+                "PiecewiseMergeJoinExec cannot embed a projection for {} 
joins",
+                self.join_type
+            );
+        }

Review Comment:
   Addressed in 
https://github.com/apache/datafusion/commit/d05143b5cabf3c155cb82dd956715f7f65a94e5d



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

Reply via email to