1use crate::parser::ast::pattern::Pattern;
2use crate::parser::ast::types::DataType;
3use linkrs_core::types::expr::contextual::ContextualExpression;
4use linkrs_core::types::{EdgeDirection, PropertyDef, Span};
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct CreateStmt {
8 pub span: Span,
9 pub target: CreateTarget,
10 pub if_not_exists: bool,
11}
12
13#[derive(Debug, Clone, PartialEq)]
14pub enum CreateTarget {
15 Node {
16 variable: Option<String>,
17 labels: Vec<String>,
18 properties: Option<ContextualExpression>,
19 },
20 Edge {
21 variable: Option<String>,
22 edge_type: String,
23 src: ContextualExpression,
24 dst: ContextualExpression,
25 properties: Option<ContextualExpression>,
26 direction: EdgeDirection,
27 },
28 Path {
29 patterns: Vec<Pattern>,
30 },
31 Tag {
32 name: String,
33 properties: Vec<PropertyDef>,
34 ttl_duration: Option<i64>,
35 ttl_col: Option<String>,
36 },
37 EdgeType {
38 name: String,
39 properties: Vec<PropertyDef>,
40 ttl_duration: Option<i64>,
41 ttl_col: Option<String>,
42 src_tag: Option<String>,
43 dst_tag: Option<String>,
44 },
45 Space {
46 name: String,
47 vid_type: String,
48 comment: Option<String>,
49 },
50 Index {
51 index_type: IndexType,
52 name: String,
53 on: String,
54 properties: Vec<String>,
55 },
56 Sequence {
57 name: String,
58 start: Option<i64>,
59 increment: Option<i64>,
60 min_value: Option<i64>,
61 max_value: Option<i64>,
62 cycle: bool,
63 },
64 TagAsQuery {
65 name: String,
66 query_text: String,
67 },
68 EdgeAsQuery {
69 name: String,
70 query_text: String,
71 },
72}
73
74#[derive(Debug, Clone, PartialEq)]
75pub enum IndexType {
76 Tag,
77 Edge,
78}
79
80#[derive(Debug, Clone, PartialEq)]
81pub struct DropStmt {
82 pub span: Span,
83 pub target: DropTarget,
84 pub if_exists: bool,
85}
86
87#[derive(Debug, Clone, PartialEq)]
88pub enum DropTarget {
89 Space(String),
90 Tags(Vec<String>),
91 Edges(Vec<String>),
92 TagIndex {
93 space_name: String,
94 index_name: String,
95 },
96 EdgeIndex {
97 space_name: String,
98 index_name: String,
99 },
100 Sequence(String),
101}
102
103#[derive(Debug, Clone, PartialEq)]
104pub struct DescStmt {
105 pub span: Span,
106 pub target: DescTarget,
107}
108
109#[derive(Debug, Clone, PartialEq)]
110pub enum DescTarget {
111 Space(String),
112 Tag {
113 space_name: String,
114 tag_name: String,
115 },
116 Edge {
117 space_name: String,
118 edge_name: String,
119 },
120}
121
122#[derive(Debug, Clone, PartialEq)]
123pub struct AlterStmt {
124 pub span: Span,
125 pub target: AlterTarget,
126}
127
128#[derive(Debug, Clone, PartialEq)]
129pub struct PropertyChange {
130 pub old_name: String,
131 pub new_name: String,
132 pub data_type: DataType,
133}
134
135#[derive(Debug, Clone, PartialEq)]
136pub enum AlterTarget {
137 Tag {
138 tag_name: String,
139 additions: Vec<PropertyDef>,
140 deletions: Vec<String>,
141 changes: Vec<PropertyChange>,
142 new_comment: Option<String>,
143 },
144 Edge {
145 edge_name: String,
146 additions: Vec<PropertyDef>,
147 deletions: Vec<String>,
148 changes: Vec<PropertyChange>,
149 new_comment: Option<String>,
150 },
151 Sequence {
152 name: String,
153 increment: Option<i64>,
154 min_value: Option<i64>,
155 max_value: Option<i64>,
156 cycle: Option<bool>,
157 },
158 RenameTag {
159 old_name: String,
160 new_name: String,
161 },
162 RenameEdge {
163 old_name: String,
164 new_name: String,
165 },
166 AddFrom {
169 edge_name: String,
170 src_tag: String,
171 dst_tag: String,
172 },
173 DropFrom {
176 edge_name: String,
177 src_tag: String,
178 dst_tag: String,
179 },
180}
181
182#[derive(Debug, Clone, PartialEq)]
183pub struct ClearSpaceStmt {
184 pub span: Span,
185 pub space_name: String,
186}
187
188#[derive(Debug, Clone, PartialEq)]
189pub struct ShowCreateStmt {
190 pub span: Span,
191 pub target: ShowCreateTarget,
192}
193
194#[derive(Debug, Clone, PartialEq)]
195pub enum ShowCreateTarget {
196 Space(String),
197 Tag(String),
198 Edge(String),
199 Index(String),
200}
201
202#[derive(Debug, Clone, PartialEq)]
204pub struct CreateMacroStmt {
205 pub span: Span,
206 pub name: String,
207 pub params: Vec<MacroParam>,
208 pub body: ContextualExpression,
209 pub if_not_exists: bool,
210}
211
212#[derive(Debug, Clone, PartialEq)]
214pub struct MacroParam {
215 pub name: String,
216 pub default_value: Option<ContextualExpression>,
217}
218
219#[derive(Debug, Clone, PartialEq)]
221pub struct DropMacroStmt {
222 pub span: Span,
223 pub name: String,
224 pub if_exists: bool,
225}
226
227#[derive(Debug, Clone, PartialEq)]
229pub struct CreateTypeStmt {
230 pub span: Span,
231 pub name: String,
232 pub underlying_type: DataType,
235 pub underlying_type_text: String,
237 pub if_not_exists: bool,
238}
239
240#[derive(Debug, Clone, PartialEq)]
242pub struct DropTypeStmt {
243 pub span: Span,
244 pub name: String,
245 pub if_exists: bool,
246}