quill_sql/plan/logical_plan/
join.rs

1use crate::catalog::SchemaRef;
2use crate::expression::Expr;
3use crate::plan::logical_plan::LogicalPlan;
4use std::sync::Arc;
5
6#[derive(derive_new::new, Debug, Clone)]
7pub struct Join {
8    pub left: Arc<LogicalPlan>,
9    pub right: Arc<LogicalPlan>,
10    pub join_type: JoinType,
11    pub condition: Option<Expr>,
12    pub schema: SchemaRef,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub enum JoinType {
17    // select * from x inner join y on ...
18    Inner,
19    // select * from x left (outer) join y on ...
20    LeftOuter,
21    // select * from x right (outer) join y on ...
22    RightOuter,
23    // select * from x full (outer) join y on ...
24    FullOuter,
25    // select * from x, y
26    // select * from x cross join y
27    Cross,
28}
29
30impl std::fmt::Display for Join {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        write!(f, "{} Join", self.join_type)?;
33        if let Some(condition) = self.condition.as_ref() {
34            write!(f, ": On {condition}")?;
35        }
36        Ok(())
37    }
38}
39
40impl std::fmt::Display for JoinType {
41    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42        write!(f, "{self:?}")
43    }
44}