pub(crate) mod lower; use std::collections::HashMap; use crate::query::ast::{AggFunc, CompOp, Literal, Param}; use crate::types::Direction; #[derive(Debug, Clone)] pub struct QueryIR { pub name: String, pub params: Vec, pub pipeline: Vec, pub return_exprs: Vec, pub order_by: Vec, pub limit: Option, } #[derive(Debug, Clone)] pub struct MutationIR { pub name: String, pub params: Vec, pub op: MutationOpIR, } #[derive(Debug, Clone)] pub enum MutationOpIR { Insert { type_name: String, assignments: Vec, }, Update { type_name: String, assignments: Vec, predicate: IRMutationPredicate, }, Delete { type_name: String, predicate: IRMutationPredicate, }, } #[derive(Debug, Clone)] pub struct IRAssignment { pub property: String, pub value: IRExpr, } #[derive(Debug, Clone)] pub struct IRMutationPredicate { pub property: String, pub op: CompOp, pub value: IRExpr, } /// Resolved runtime parameters: param name → literal value. pub type ParamMap = HashMap; #[derive(Debug, Clone)] pub enum IROp { NodeScan { variable: String, type_name: String, filters: Vec, }, Expand { src_var: String, dst_var: String, edge_type: String, direction: Direction, dst_type: String, min_hops: u32, max_hops: Option, }, Filter(IRFilter), AntiJoin { /// The outer variable whose id is used for the join key outer_var: String, /// The inner pipeline that produces rows to anti-join against inner: Vec, }, } #[derive(Debug, Clone)] pub struct IRFilter { pub left: IRExpr, pub op: CompOp, pub right: IRExpr, } #[derive(Debug, Clone)] pub enum IRExpr { PropAccess { variable: String, property: String, }, Nearest { variable: String, property: String, query: Box, }, Search { field: Box, query: Box, }, Fuzzy { field: Box, query: Box, max_edits: Option>, }, MatchText { field: Box, query: Box, }, Bm25 { field: Box, query: Box, }, Rrf { primary: Box, secondary: Box, k: Option>, }, Variable(String), Param(String), Literal(Literal), Aggregate { func: AggFunc, arg: Box, }, AliasRef(String), } #[derive(Debug, Clone)] pub struct IRProjection { pub expr: IRExpr, pub alias: Option, } #[derive(Debug, Clone)] pub struct IROrdering { pub expr: IRExpr, pub descending: bool, }