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

Method using_columns

datafusion/expr/src/logical_plan/plan.rs:492–525  ·  view source on GitHub ↗

returns all `Using` join columns in a logical plan

(&self)

Source from the content-addressed store, hash-verified

490
491 /// returns all `Using` join columns in a logical plan
492 pub fn using_columns(&self) -> Result<Vec<HashSet<Column>>, DataFusionError> {
493 let mut using_columns: Vec<HashSet<Column>> = vec![];
494
495 self.apply_with_subqueries(|plan| {
496 if let LogicalPlan::Join(Join {
497 join_constraint: JoinConstraint::Using,
498 on,
499 ..
500 }) = plan
501 {
502 // The join keys in using-join must be columns.
503 let columns =
504 on.iter().try_fold(HashSet::new(), |mut accumu, (l, r)| {
505 let Some(l) = l.get_as_join_column() else {
506 return internal_err!(
507 "Invalid join key. Expected column, found {l:?}"
508 );
509 };
510 let Some(r) = r.get_as_join_column() else {
511 return internal_err!(
512 "Invalid join key. Expected column, found {r:?}"
513 );
514 };
515 accumu.insert(l.to_owned());
516 accumu.insert(r.to_owned());
517 Result::<_, DataFusionError>::Ok(accumu)
518 })?;
519 using_columns.push(columns);
520 }
521 Ok(TreeNodeRecursion::Continue)
522 })?;
523
524 Ok(using_columns)
525 }
526
527 /// returns the first output expression of this `LogicalPlan` node.
528 pub fn head_output_expr(&self) -> Result<Option<Expr>> {

Callers 3

exclude_using_columnsFunction · 0.80
normalizeMethod · 0.80
sql_select_to_rexMethod · 0.80

Calls 6

newFunction · 0.85
apply_with_subqueriesMethod · 0.80
get_as_join_columnMethod · 0.80
iterMethod · 0.45
insertMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected