comphead commented on code in PR #10431:
URL: https://github.com/apache/datafusion/pull/10431#discussion_r1598631511


##########
datafusion/optimizer/src/eliminate_cross_join.rs:
##########
@@ -144,49 +191,89 @@ impl OptimizerRule for EliminateCrossJoin {
     }
 }
 
+fn rewrite_children(
+    optimizer: &impl OptimizerRule,
+    plan: LogicalPlan,
+    config: &dyn OptimizerConfig,
+) -> Result<Transformed<LogicalPlan>> {
+    let transformed_plan = plan.map_children(|input| optimizer.rewrite(input, 
config))?;
+
+    // recompute schema if the plan was transformed
+    if transformed_plan.transformed {
+        transformed_plan.map_data(|plan| plan.recompute_schema())
+    } else {
+        Ok(transformed_plan)
+    }
+}
+
 /// Recursively accumulate possible_join_keys and inputs from inner joins
 /// (including cross joins).
 ///
-/// Returns a boolean indicating whether the flattening was successful.
-fn try_flatten_join_inputs(
-    plan: &LogicalPlan,
+/// Assumes can_flatten_join_inputs has returned true and thus the plan can be
+/// flattened. Adds all leaf inputs to `all_inputs` and join_keys to
+/// possible_join_keys
+fn flatten_join_inputs(
+    plan: LogicalPlan,
     possible_join_keys: &mut JoinKeySet,
     all_inputs: &mut Vec<LogicalPlan>,
-) -> Result<bool> {
-    let children = match plan {
+) -> Result<()> {
+    match plan {
         LogicalPlan::Join(join) if join.join_type == JoinType::Inner => {
+            // checked in can_flatten_join_inputs
             if join.filter.is_some() {
-                // The filter of inner join will lost, skip this rule.
-                // issue: https://github.com/apache/datafusion/issues/4844
-                return Ok(false);
+                return internal_err!(

Review Comment:
   👍 



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