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

Function collect_columns

datafusion/physical-expr/src/utils/mod.rs:286–297  ·  view source on GitHub ↗

Recursively extract referenced [`Column`]s within a [`PhysicalExpr`].

(expr: &Arc<dyn PhysicalExpr>)

Source from the content-addressed store, hash-verified

284
285/// Recursively extract referenced [`Column`]s within a [`PhysicalExpr`].
286pub 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`].

Calls 3

newFunction · 0.85
applyMethod · 0.45
cloneMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…