MCPcopy Create free account
hub / github.com/apache/datafusion / flatten_join_inputs

Function flatten_join_inputs

datafusion/optimizer/src/eliminate_cross_join.rs:236–266  ·  view source on GitHub ↗

Recursively accumulate possible_join_keys and inputs from inner joins (including cross joins). 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

(
    plan: LogicalPlan,
    possible_join_keys: &mut JoinKeySet,
    all_inputs: &mut Vec<LogicalPlan>,
    all_filters: &mut Vec<Expr>,
)

Source from the content-addressed store, hash-verified

234/// flattened. Adds all leaf inputs to `all_inputs` and join_keys to
235/// possible_join_keys
236fn flatten_join_inputs(
237 plan: LogicalPlan,
238 possible_join_keys: &mut JoinKeySet,
239 all_inputs: &mut Vec<LogicalPlan>,
240 all_filters: &mut Vec<Expr>,
241) -> Result<()> {
242 match plan {
243 LogicalPlan::Join(join) if join.join_type == JoinType::Inner => {
244 if let Some(filter) = join.filter {
245 all_filters.push(filter);
246 }
247 possible_join_keys.insert_all_owned(join.on);
248 flatten_join_inputs(
249 Arc::unwrap_or_clone(join.left),
250 possible_join_keys,
251 all_inputs,
252 all_filters,
253 )?;
254 flatten_join_inputs(
255 Arc::unwrap_or_clone(join.right),
256 possible_join_keys,
257 all_inputs,
258 all_filters,
259 )?;
260 }
261 _ => {
262 all_inputs.push(plan);
263 }
264 };
265 Ok(())
266}
267
268/// Returns true if the plan is a Join or Cross join could be flattened with
269/// `flatten_join_inputs`

Callers 1

rewriteMethod · 0.85

Calls 2

insert_all_ownedMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…