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