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

Function find_unnest_node_within_select

datafusion/sql/src/unparser/utils.rs:76–95  ·  view source on GitHub ↗

Recursively searches children of [LogicalPlan] to find Unnest node if exist

(plan: &LogicalPlan)

Source from the content-addressed store, hash-verified

74
75/// Recursively searches children of [LogicalPlan] to find Unnest node if exist
76pub(crate) fn find_unnest_node_within_select(plan: &LogicalPlan) -> Option<&Unnest> {
77 // Note that none of the nodes that have a corresponding node can have more
78 // than 1 input node. E.g. Projection / Filter always have 1 input node.
79 let input = plan.inputs();
80 let input = if input.len() > 1 {
81 return None;
82 } else {
83 input.first()?
84 };
85
86 if let LogicalPlan::Unnest(unnest) = input {
87 Some(unnest)
88 } else if let LogicalPlan::TableScan(_) = input {
89 None
90 } else if let LogicalPlan::Projection(_) = input {
91 None
92 } else {
93 find_unnest_node_within_select(input)
94 }
95}
96
97/// Recursively searches children of [LogicalPlan] to find Unnest node if exist
98/// until encountering a Relation node with single input

Calls 3

inputsMethod · 0.45
lenMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…