1use lora_analyzer::symbols::VarId;
2use lora_analyzer::{
3 ResolvedExpr, ResolvedMergeAction, ResolvedPattern, ResolvedPatternPart, ResolvedProjection,
4 ResolvedRemoveItem, ResolvedSetItem, ResolvedSortItem,
5};
6use lora_ast::{Direction, RangeLiteral};
7
8pub type PhysicalNodeId = usize;
9
10#[derive(Debug, Clone)]
11pub struct PhysicalPlan {
12 pub root: PhysicalNodeId,
13 pub nodes: Vec<PhysicalOp>,
14}
15
16#[derive(Debug, Clone)]
17pub enum PhysicalOp {
18 Argument(ArgumentExec),
19 NodeScan(NodeScanExec),
20 NodeByLabelScan(NodeByLabelScanExec),
21 NodeByPropertyScan(NodeByPropertyScanExec),
22 Expand(ExpandExec),
23 Filter(FilterExec),
24 Projection(ProjectionExec),
25 Unwind(UnwindExec),
26 HashAggregation(HashAggregationExec),
27 Sort(SortExec),
28 Limit(LimitExec),
29 Create(CreateExec),
30 Merge(MergeExec),
31 Delete(DeleteExec),
32 Set(SetExec),
33 Remove(RemoveExec),
34 OptionalMatch(OptionalMatchExec),
35 PathBuild(PathBuildExec),
36}
37
38#[derive(Debug, Clone)]
39pub struct PathBuildExec {
40 pub input: PhysicalNodeId,
41 pub output: VarId,
42 pub node_vars: Vec<VarId>,
43 pub rel_vars: Vec<VarId>,
44 pub shortest_path_all: Option<bool>,
45}
46
47#[derive(Debug, Clone)]
50pub struct OptionalMatchExec {
51 pub input: PhysicalNodeId,
52 pub inner: PhysicalNodeId,
53 pub new_vars: Vec<VarId>,
54}
55
56#[derive(Debug, Clone)]
57pub struct ArgumentExec;
58
59#[derive(Debug, Clone)]
60pub struct NodeScanExec {
61 pub input: Option<PhysicalNodeId>,
62 pub var: VarId,
63}
64
65#[derive(Debug, Clone)]
66pub struct NodeByLabelScanExec {
67 pub input: Option<PhysicalNodeId>,
68 pub var: VarId,
69 pub labels: Vec<Vec<String>>,
71}
72
73#[derive(Debug, Clone)]
74pub struct NodeByPropertyScanExec {
75 pub input: Option<PhysicalNodeId>,
76 pub var: VarId,
77 pub labels: Vec<Vec<String>>,
79 pub key: String,
80 pub value: ResolvedExpr,
81}
82
83#[derive(Debug, Clone)]
84pub struct ExpandExec {
85 pub input: PhysicalNodeId,
86 pub src: VarId,
87 pub rel: Option<VarId>,
88 pub dst: VarId,
89 pub types: Vec<String>,
90 pub direction: Direction,
91 pub rel_properties: Option<ResolvedExpr>,
92 pub range: Option<RangeLiteral>,
93}
94
95#[derive(Debug, Clone)]
96pub struct FilterExec {
97 pub input: PhysicalNodeId,
98 pub predicate: ResolvedExpr,
99}
100
101#[derive(Debug, Clone)]
102pub struct ProjectionExec {
103 pub input: PhysicalNodeId,
104 pub distinct: bool,
105 pub items: Vec<ResolvedProjection>,
106 pub include_existing: bool,
107}
108
109#[derive(Debug, Clone)]
110pub struct UnwindExec {
111 pub input: PhysicalNodeId,
112 pub expr: ResolvedExpr,
113 pub alias: VarId,
114}
115
116#[derive(Debug, Clone)]
117pub struct HashAggregationExec {
118 pub input: PhysicalNodeId,
119 pub group_by: Vec<ResolvedProjection>,
120 pub aggregates: Vec<ResolvedProjection>,
121}
122
123#[derive(Debug, Clone)]
124pub struct SortExec {
125 pub input: PhysicalNodeId,
126 pub items: Vec<ResolvedSortItem>,
127}
128
129#[derive(Debug, Clone)]
130pub struct LimitExec {
131 pub input: PhysicalNodeId,
132 pub skip: Option<ResolvedExpr>,
133 pub limit: Option<ResolvedExpr>,
134}
135
136#[derive(Debug, Clone)]
137pub struct CreateExec {
138 pub input: PhysicalNodeId,
139 pub pattern: ResolvedPattern,
140}
141
142#[derive(Debug, Clone)]
143pub struct MergeExec {
144 pub input: PhysicalNodeId,
145 pub pattern_part: ResolvedPatternPart,
146 pub actions: Vec<ResolvedMergeAction>,
147}
148
149#[derive(Debug, Clone)]
150pub struct DeleteExec {
151 pub input: PhysicalNodeId,
152 pub detach: bool,
153 pub expressions: Vec<ResolvedExpr>,
154}
155
156#[derive(Debug, Clone)]
157pub struct SetExec {
158 pub input: PhysicalNodeId,
159 pub items: Vec<ResolvedSetItem>,
160}
161
162#[derive(Debug, Clone)]
163pub struct RemoveExec {
164 pub input: PhysicalNodeId,
165 pub items: Vec<ResolvedRemoveItem>,
166}