yashaggarwal85d commented on code in PR #26558:
URL: https://github.com/apache/datafusion/pull/26558#discussion_r4399677703


##########
datafusion/optimizer/src/analyzer/type_coercion.rs:
##########
@@ -311,6 +311,65 @@ impl<'a> TypeCoercionRewriter<'a> {
         self
     }
 
+    /// Coerce a subquery whose outer plan has been coerced into `self.schema`.
+    ///
+    /// The subquery was coerced before its outer plan, against the types its
+    /// outer reference columns had when the plan was built. Coercing the outer
+    /// plan can change those types, for example for a `CASE` with `INT` and
+    /// `BIGINT` branches or a `UNION` of `INT` and `BIGINT` columns. In that
+    /// case the outer references take the new types and the subquery is
+    /// coerced again, so that its comparisons with them are coerced too.
+    fn coerce_subquery(&self, subquery: Subquery) -> Result<Subquery> {

Review Comment:
   Agreed. The plan walk no longer goes into subqueries on its own. The 
rewriter coerces a subquery when it reaches it, with the outer node's schema, 
so every node gets coerced once (before, the subquery root was coerced twice)



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