|
| 1 | +use std::sync::Arc; |
| 2 | + |
| 3 | +use arrow_schema::DataType; |
| 4 | + |
| 5 | +use super::{ |
| 6 | + predicates::{ |
| 7 | + bin_op_pred::BinOpType, constant_pred::ConstantType, func_pred::FuncType, |
| 8 | + log_op_pred::LogOpType, sort_order_pred::SortOrderType, un_op_pred::UnOpType, |
| 9 | + }, |
| 10 | + values::Value, |
| 11 | +}; |
| 12 | + |
| 13 | +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
| 14 | +pub enum JoinType { |
| 15 | + Inner = 1, |
| 16 | + FullOuter, |
| 17 | + LeftOuter, |
| 18 | + RightOuter, |
| 19 | + Cross, |
| 20 | + LeftSemi, |
| 21 | + RightSemi, |
| 22 | + LeftAnti, |
| 23 | + RightAnti, |
| 24 | +} |
| 25 | + |
| 26 | +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 27 | +pub enum PhysicalNodeType { |
| 28 | + PhysicalProjection, |
| 29 | + PhysicalFilter, |
| 30 | + PhysicalScan, |
| 31 | + PhysicalSort, |
| 32 | + PhysicalAgg, |
| 33 | + PhysicalHashJoin(JoinType), |
| 34 | + PhysicalNestedLoopJoin(JoinType), |
| 35 | + PhysicalEmptyRelation, |
| 36 | + PhysicalLimit, |
| 37 | +} |
| 38 | + |
| 39 | +impl std::fmt::Display for PhysicalNodeType { |
| 40 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 41 | + write!(f, "{:?}", self) |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +#[derive(Debug, Clone, PartialEq, Eq, Hash)] |
| 46 | +pub enum PredicateType { |
| 47 | + List, |
| 48 | + Constant(ConstantType), |
| 49 | + ColumnRef, |
| 50 | + ExternColumnRef, |
| 51 | + UnOp(UnOpType), |
| 52 | + BinOp(BinOpType), |
| 53 | + LogOp(LogOpType), |
| 54 | + Func(FuncType), |
| 55 | + SortOrder(SortOrderType), |
| 56 | + Between, |
| 57 | + Cast, |
| 58 | + Like, |
| 59 | + DataType(DataType), |
| 60 | + InList, |
| 61 | +} |
| 62 | + |
| 63 | +impl std::fmt::Display for PredicateType { |
| 64 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 65 | + write!(f, "{:?}", self) |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +pub type ArcPredicateNode = Arc<PredicateNode>; |
| 70 | + |
| 71 | +#[derive(Clone, Debug, Hash, PartialEq, Eq)] |
| 72 | +pub struct PredicateNode { |
| 73 | + /// A generic predicate node type |
| 74 | + pub typ: PredicateType, |
| 75 | + /// Child predicate nodes, always materialized |
| 76 | + pub children: Vec<PredicateNode>, |
| 77 | + /// Data associated with the predicate, if any |
| 78 | + pub data: Option<Value>, |
| 79 | +} |
| 80 | + |
| 81 | +impl std::fmt::Display for PredicateNode { |
| 82 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 83 | + write!(f, "({}", self.typ)?; |
| 84 | + for child in &self.children { |
| 85 | + write!(f, " {}", child)?; |
| 86 | + } |
| 87 | + if let Some(data) = &self.data { |
| 88 | + write!(f, " {}", data)?; |
| 89 | + } |
| 90 | + write!(f, ")") |
| 91 | + } |
| 92 | +} |
0 commit comments