Skip to main content

kyu_executor/
physical_plan.rs

1//! Physical operator enum — pull-based execution via `next()`.
2
3use kyu_common::KyuResult;
4
5use crate::context::ExecutionContext;
6use crate::data_chunk::DataChunk;
7use crate::operators::*;
8
9/// A physical operator. Enum dispatch for branch-predictable execution.
10pub enum PhysicalOperator {
11    ScanNode(ScanNodeOp),
12    Filter(FilterOp),
13    Projection(ProjectionOp),
14    HashJoin(HashJoinOp),
15    CrossProduct(CrossProductOp),
16    Aggregate(AggregateOp),
17    OrderBy(OrderByOp),
18    Limit(LimitOp),
19    Distinct(DistinctOp),
20    RecursiveJoin(RecursiveJoinOp),
21    ShortestPath(ShortestPathOp),
22    Unwind(UnwindOp),
23    Empty(EmptyOp),
24}
25
26impl PhysicalOperator {
27    /// Pull the next batch of rows. Returns `None` when exhausted.
28    pub fn next(&mut self, ctx: &ExecutionContext<'_>) -> KyuResult<Option<DataChunk>> {
29        match self {
30            Self::ScanNode(op) => op.next(ctx),
31            Self::Filter(op) => op.next(ctx),
32            Self::Projection(op) => op.next(ctx),
33            Self::HashJoin(op) => op.next(ctx),
34            Self::CrossProduct(op) => op.next(ctx),
35            Self::Aggregate(op) => op.next(ctx),
36            Self::OrderBy(op) => op.next(ctx),
37            Self::Limit(op) => op.next(ctx),
38            Self::Distinct(op) => op.next(ctx),
39            Self::RecursiveJoin(op) => op.next(ctx),
40            Self::ShortestPath(op) => op.next(ctx),
41            Self::Unwind(op) => op.next(ctx),
42            Self::Empty(op) => op.next(ctx),
43        }
44    }
45}