use std::sync::Arc;
#[derive(Debug, Clone, PartialEq)]
pub enum CypherStatement {
Match {
optional: bool,
pattern: Vec<CypherPattern>,
where_clause: Option<CypherExpr>,
return_clause: CypherReturn,
temporal: Option<CypherTemporal>,
with_clauses: Vec<CypherWith>,
},
}
#[derive(Debug, Clone, PartialEq)]
pub struct CypherPattern {
pub elements: Vec<CypherPatternElement>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CypherPatternElement {
Node(CypherNodePattern),
Relationship(CypherRelPattern),
}
#[derive(Debug, Clone, PartialEq)]
pub struct CypherNodePattern {
pub variable: Option<String>,
pub labels: Vec<String>,
pub properties: Vec<(String, CypherValue)>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CypherRelPattern {
pub variable: Option<String>,
pub rel_types: Vec<String>,
pub direction: CypherDirection,
pub depth: Option<CypherDepth>,
pub properties: Vec<(String, CypherValue)>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CypherDirection {
Outgoing,
Incoming,
Both,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CypherDepth {
Unbounded,
Exact(usize),
Max(usize),
Min(usize),
Range {
min: usize,
max: usize,
},
}
#[derive(Debug, Clone, PartialEq)]
pub enum CypherValue {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
Parameter(String),
Vector(Arc<[f32]>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum CypherExpr {
Value(CypherValue),
Variable(String),
Property {
variable: String,
property: String,
},
Comparison {
left: Box<CypherExpr>,
op: CypherCompOp,
right: Box<CypherExpr>,
},
And(Box<CypherExpr>, Box<CypherExpr>),
Or(Box<CypherExpr>, Box<CypherExpr>),
Not(Box<CypherExpr>),
IsNull(Box<CypherExpr>),
IsNotNull(Box<CypherExpr>),
In {
expr: Box<CypherExpr>,
values: Vec<CypherExpr>,
},
Contains {
expr: Box<CypherExpr>,
substring: String,
},
StartsWith {
expr: Box<CypherExpr>,
prefix: String,
},
EndsWith {
expr: Box<CypherExpr>,
suffix: String,
},
FunctionCall {
name: String,
args: Vec<CypherExpr>,
},
Grouped(Box<CypherExpr>),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CypherCompOp {
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CypherReturn {
pub distinct: bool,
pub items: Vec<CypherReturnItem>,
pub order_by: Vec<CypherOrderItem>,
pub skip: Option<usize>,
pub limit: Option<usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CypherReturnItem {
Star,
Variable(String),
Expression {
expr: CypherExpr,
alias: Option<String>,
},
}
#[derive(Debug, Clone, PartialEq)]
pub struct CypherOrderItem {
pub expr: CypherExpr,
pub descending: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CypherTemporal {
AsOfTimestamp(String),
AsOfValidTime(String),
AsOfSystemTime(String),
BiTemporal {
valid_time: String,
system_time: String,
},
Between {
start: String,
end: String,
},
}
#[derive(Debug, Clone, PartialEq)]
pub struct CypherWith {
pub items: Vec<CypherReturnItem>,
pub where_clause: Option<CypherExpr>,
}