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>,
)
| 234 | /// flattened. Adds all leaf inputs to `all_inputs` and join_keys to |
| 235 | /// possible_join_keys |
| 236 | fn 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` |
no test coverage detected
searching dependent graphs…