mod columnar;
mod context;
mod native_columnar;
mod row_oriented;
mod types;
pub use columnar::ColumnarPipeline;
pub use context::ExecutionContext;
pub use native_columnar::NativeColumnarPipeline;
pub use row_oriented::RowOrientedPipeline;
pub use types::{PipelineInput, PipelineOutput};
use vibesql_ast::{Expression, SelectItem};
use crate::{errors::ExecutorError, evaluator::CombinedExpressionEvaluator};
pub trait ExecutionPipeline {
#[inline]
fn create_evaluator<'a>(
&self,
ctx: &'a ExecutionContext<'a>,
) -> CombinedExpressionEvaluator<'a> {
ctx.create_evaluator()
}
fn apply_filter(
&self,
input: PipelineInput<'_>,
predicate: Option<&Expression>,
ctx: &ExecutionContext<'_>,
) -> Result<PipelineOutput, ExecutorError>;
fn apply_projection(
&self,
input: PipelineInput<'_>,
select_items: &[SelectItem],
ctx: &ExecutionContext<'_>,
) -> Result<PipelineOutput, ExecutorError>;
fn apply_aggregation(
&self,
input: PipelineInput<'_>,
select_items: &[SelectItem],
group_by: Option<&[Expression]>,
having: Option<&Expression>,
ctx: &ExecutionContext<'_>,
) -> Result<PipelineOutput, ExecutorError>;
#[inline]
fn apply_limit_offset(
&self,
input: PipelineOutput,
limit: Option<u64>,
offset: Option<u64>,
) -> Result<Vec<vibesql_storage::Row>, ExecutorError> {
let mut rows = input.into_rows();
if let Some(off) = offset {
let off = off as usize;
if off >= rows.len() {
return Ok(Vec::new());
}
rows = rows.into_iter().skip(off).collect();
}
if let Some(lim) = limit {
rows.truncate(lim as usize);
}
Ok(rows)
}
fn supports_query_pattern(
&self,
has_aggregation: bool,
has_group_by: bool,
has_joins: bool,
) -> bool;
fn name(&self) -> &'static str;
}