returns all `Using` join columns in a logical plan
(&self)
| 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>> { |
no test coverage detected