Recursively extract referenced [`Column`]s within a [`PhysicalExpr`].
(expr: &Arc<dyn PhysicalExpr>)
| 284 | |
| 285 | /// Recursively extract referenced [`Column`]s within a [`PhysicalExpr`]. |
| 286 | pub fn collect_columns(expr: &Arc<dyn PhysicalExpr>) -> HashSet<Column> { |
| 287 | let mut columns = HashSet::<Column>::new(); |
| 288 | expr.apply(|expr| { |
| 289 | if let Some(column) = expr.downcast_ref::<Column>() { |
| 290 | columns.get_or_insert_with(column, |c| c.clone()); |
| 291 | } |
| 292 | Ok(TreeNodeRecursion::Continue) |
| 293 | }) |
| 294 | // pre_visit always returns OK, so this will always too |
| 295 | .expect("no way to return error during recursion"); |
| 296 | columns |
| 297 | } |
| 298 | |
| 299 | /// Re-assign indices of [`Column`]s within the given [`PhysicalExpr`] according to |
| 300 | /// the provided [`Schema`]. |
searching dependent graphs…