gqlite 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/Cargo.toml +12 -6
- data/ext/db-index/Cargo.toml +29 -0
- data/ext/db-index/src/hnsw/error.rs +66 -0
- data/ext/db-index/src/hnsw/graph_store.rs +272 -0
- data/ext/db-index/src/hnsw/id.rs +36 -0
- data/ext/db-index/src/hnsw/implementation.rs +1517 -0
- data/ext/db-index/src/hnsw/kernels.rs +1228 -0
- data/ext/db-index/src/hnsw/metric.rs +244 -0
- data/ext/db-index/src/hnsw/scalar.rs +72 -0
- data/ext/db-index/src/hnsw/simple_store.rs +140 -0
- data/ext/db-index/src/hnsw/store.rs +472 -0
- data/ext/db-index/src/hnsw/vector.rs +105 -0
- data/ext/db-index/src/hnsw/vectors.rs +568 -0
- data/ext/db-index/src/hnsw.rs +42 -0
- data/ext/db-index/src/lib.rs +3 -0
- data/ext/gqlitedb/Cargo.toml +19 -8
- data/ext/gqlitedb/benches/common/pokec.rs +62 -2
- data/ext/gqlitedb/benches/pokec_divan.rs +66 -2
- data/ext/gqlitedb/benches/pokec_iai.rs +60 -3
- data/ext/gqlitedb/release.toml +2 -2
- data/ext/gqlitedb/src/aggregators/arithmetic.rs +3 -1
- data/ext/gqlitedb/src/aggregators/containers.rs +1 -1
- data/ext/gqlitedb/src/aggregators/stats.rs +21 -12
- data/ext/gqlitedb/src/capi.rs +20 -24
- data/ext/gqlitedb/src/compiler/expression_analyser.rs +28 -20
- data/ext/gqlitedb/src/compiler/variables_manager.rs +104 -38
- data/ext/gqlitedb/src/compiler.rs +506 -227
- data/ext/gqlitedb/src/connection.rs +151 -11
- data/ext/gqlitedb/src/consts.rs +1 -2
- data/ext/gqlitedb/src/error.rs +123 -61
- data/ext/gqlitedb/src/functions/common.rs +64 -0
- data/ext/gqlitedb/src/functions/containers.rs +2 -46
- data/ext/gqlitedb/src/functions/edge.rs +1 -1
- data/ext/gqlitedb/src/functions/math.rs +87 -15
- data/ext/gqlitedb/src/functions/node.rs +1 -1
- data/ext/gqlitedb/src/functions/path.rs +48 -11
- data/ext/gqlitedb/src/functions/scalar.rs +47 -4
- data/ext/gqlitedb/src/functions/string.rs +123 -1
- data/ext/gqlitedb/src/functions/value.rs +1 -1
- data/ext/gqlitedb/src/functions.rs +165 -28
- data/ext/gqlitedb/src/graph.rs +1 -9
- data/ext/gqlitedb/src/interpreter/evaluators.rs +968 -130
- data/ext/gqlitedb/src/interpreter/instructions.rs +39 -2
- data/ext/gqlitedb/src/lib.rs +5 -4
- data/ext/gqlitedb/src/parser/gql.pest +1 -1
- data/ext/gqlitedb/src/planner.rs +329 -0
- data/ext/gqlitedb/src/prelude.rs +3 -3
- data/ext/gqlitedb/src/store/pgrx.rs +1 -1
- data/ext/gqlitedb/src/store/postgres.rs +742 -16
- data/ext/gqlitedb/src/store/redb/hnsw_store.rs +702 -0
- data/ext/gqlitedb/src/store/redb/index.rs +274 -0
- data/ext/gqlitedb/src/store/redb.rs +1268 -113
- data/ext/gqlitedb/src/store/sqlbase/sqlmetadata.rs +28 -0
- data/ext/gqlitedb/src/store/sqlbase/sqlstore.rs +103 -0
- data/ext/gqlitedb/src/store/sqlbase.rs +146 -16
- data/ext/gqlitedb/src/store/sqlite.rs +576 -14
- data/ext/gqlitedb/src/store/vector_extract.rs +56 -0
- data/ext/gqlitedb/src/store.rs +140 -29
- data/ext/gqlitedb/src/tests/compiler.rs +207 -10
- data/ext/gqlitedb/src/tests/connection/postgres.rs +38 -3
- data/ext/gqlitedb/src/tests/connection/redb.rs +23 -0
- data/ext/gqlitedb/src/tests/connection/sqlite.rs +31 -0
- data/ext/gqlitedb/src/tests/connection.rs +61 -1
- data/ext/gqlitedb/src/tests/evaluators.rs +162 -7
- data/ext/gqlitedb/src/tests/parser.rs +54 -23
- data/ext/gqlitedb/src/tests/planner.rs +511 -0
- data/ext/gqlitedb/src/tests/store/postgres.rs +7 -0
- data/ext/gqlitedb/src/tests/store/redb.rs +8 -0
- data/ext/gqlitedb/src/tests/store/sqlite.rs +8 -0
- data/ext/gqlitedb/src/tests/store/vector_index/postgres.rs +182 -0
- data/ext/gqlitedb/src/tests/store/vector_index/redb.rs +386 -0
- data/ext/gqlitedb/src/tests/store/vector_index/sqlite.rs +166 -0
- data/ext/gqlitedb/src/tests/store/vector_index.rs +2313 -0
- data/ext/gqlitedb/src/tests/store.rs +78 -14
- data/ext/gqlitedb/src/tests/templates/ast.rs +92 -16
- data/ext/gqlitedb/src/tests/templates/programs.rs +14 -7
- data/ext/gqlitedb/src/tests.rs +15 -9
- data/ext/gqlitedb/src/utils.rs +6 -1
- data/ext/gqlitedb/src/value/compare.rs +61 -3
- data/ext/gqlitedb/src/value.rs +136 -7
- data/ext/gqlitedb/templates/sql/postgres/metadata_delete.sql +1 -0
- data/ext/gqlitedb/templates/sql/postgres/node_select.sql +1 -1
- data/ext/gqlitedb/templates/sql/sqlite/metadata_delete.sql +1 -0
- data/ext/gqliterb/src/lib.rs +53 -8
- data/ext/gqlparser/Cargo.toml +25 -0
- data/ext/gqlparser/README.MD +9 -0
- data/ext/gqlparser/benches/pokec_divan.rs +34 -0
- data/ext/gqlparser/src/common.rs +69 -0
- data/ext/gqlparser/src/gqls/ast.rs +69 -0
- data/ext/gqlparser/src/gqls/constraint.rs +79 -0
- data/ext/gqlparser/src/gqls/error.rs +22 -0
- data/ext/gqlparser/src/gqls/parser.rs +813 -0
- data/ext/gqlparser/src/gqls/prelude.rs +8 -0
- data/ext/gqlparser/src/gqls/properties.rs +115 -0
- data/ext/gqlparser/src/gqls/resolve.rs +207 -0
- data/ext/gqlparser/src/gqls.rs +265 -0
- data/ext/gqlparser/src/lib.rs +7 -0
- data/ext/gqlparser/src/oc/ast.rs +680 -0
- data/ext/gqlparser/src/oc/error.rs +172 -0
- data/ext/gqlparser/src/oc/lexer.rs +429 -0
- data/ext/gqlparser/src/oc/parser/tests.rs +2284 -0
- data/ext/gqlparser/src/oc/parser.rs +2005 -0
- data/ext/gqlparser/src/oc.rs +33 -0
- data/ext/gqlparser/src/prelude.rs +3 -0
- data/ext/graphcore/Cargo.toml +1 -0
- data/ext/graphcore/src/error.rs +26 -0
- data/ext/graphcore/src/graph.rs +177 -51
- data/ext/graphcore/src/lib.rs +4 -2
- data/ext/graphcore/src/open_cypher.rs +12 -0
- data/ext/graphcore/src/table.rs +50 -2
- data/ext/graphcore/src/timestamp.rs +127 -104
- data/ext/graphcore/src/value/tensor.rs +739 -0
- data/ext/graphcore/src/value/value_map.rs +1 -1
- data/ext/graphcore/src/value.rs +343 -19
- metadata +93 -28
- data/ext/gqlitedb/src/parser/ast.rs +0 -604
- data/ext/gqlitedb/src/parser/parser_impl.rs +0 -1213
- data/ext/gqlitedb/src/parser.rs +0 -4
|
@@ -83,11 +83,20 @@ pub(crate) enum Instruction
|
|
|
83
83
|
|
|
84
84
|
pub(crate) type Instructions = Vec<Instruction>;
|
|
85
85
|
|
|
86
|
+
#[derive(Debug, Default)]
|
|
87
|
+
pub(crate) struct CreateActionVariable
|
|
88
|
+
{
|
|
89
|
+
/// For node/edge
|
|
90
|
+
pub(crate) element: Option<ColId>,
|
|
91
|
+
/// For edges, an optional path variable
|
|
92
|
+
pub(crate) path: Option<ColId>,
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
#[derive(Debug)]
|
|
87
96
|
pub(crate) struct CreateAction
|
|
88
97
|
{
|
|
89
98
|
pub(crate) instructions: Instructions,
|
|
90
|
-
pub(crate) variables: Vec<
|
|
99
|
+
pub(crate) variables: Vec<CreateActionVariable>,
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
#[derive(Debug)]
|
|
@@ -107,7 +116,8 @@ pub(crate) enum BlockMatch
|
|
|
107
116
|
right_variable: Option<ColId>,
|
|
108
117
|
path_variable: Option<ColId>,
|
|
109
118
|
filter: Instructions,
|
|
110
|
-
directivity:
|
|
119
|
+
directivity: graphcore::EdgeDirectivity,
|
|
120
|
+
recursive_range: Option<std::ops::Range<usize>>,
|
|
111
121
|
},
|
|
112
122
|
}
|
|
113
123
|
|
|
@@ -265,4 +275,31 @@ pub(crate) enum Block
|
|
|
265
275
|
updates: Vec<UpdateOne>,
|
|
266
276
|
variables_size: VariablesSizes,
|
|
267
277
|
},
|
|
278
|
+
Merge
|
|
279
|
+
{
|
|
280
|
+
match_blocks: Vec<BlockMatch>,
|
|
281
|
+
match_filter: Instructions,
|
|
282
|
+
create_actions: Vec<CreateAction>,
|
|
283
|
+
on_create_updates: Vec<UpdateOne>,
|
|
284
|
+
on_match_updates: Vec<UpdateOne>,
|
|
285
|
+
variables_size: VariablesSizes,
|
|
286
|
+
},
|
|
287
|
+
VectorSearch
|
|
288
|
+
{
|
|
289
|
+
index: String,
|
|
290
|
+
query_instructions: Instructions,
|
|
291
|
+
k: usize,
|
|
292
|
+
out_node_col_id: ColId,
|
|
293
|
+
out_score_col_id: Option<ColId>,
|
|
294
|
+
variables_size: VariablesSizes,
|
|
295
|
+
},
|
|
296
|
+
CreateVectorIndex
|
|
297
|
+
{
|
|
298
|
+
name: String,
|
|
299
|
+
label: String,
|
|
300
|
+
property: String,
|
|
301
|
+
dimension: Option<usize>,
|
|
302
|
+
metric: Option<gqlparser::oc::ast::Metric>,
|
|
303
|
+
if_not_exists: bool,
|
|
304
|
+
},
|
|
268
305
|
}
|
data/ext/gqlitedb/src/lib.rs
CHANGED
|
@@ -19,7 +19,7 @@ mod error;
|
|
|
19
19
|
mod functions;
|
|
20
20
|
mod graph;
|
|
21
21
|
mod interpreter;
|
|
22
|
-
mod
|
|
22
|
+
mod planner;
|
|
23
23
|
mod prelude;
|
|
24
24
|
mod query_result;
|
|
25
25
|
mod store;
|
|
@@ -33,12 +33,13 @@ pub(crate) mod tests;
|
|
|
33
33
|
pub use {
|
|
34
34
|
connection::{Backend, Connection},
|
|
35
35
|
error::{CompileTimeError, Error, RunTimeError, StoreError},
|
|
36
|
-
graph::{
|
|
36
|
+
graph::{Edge, Node, Path, SinglePath, labels},
|
|
37
|
+
planner::{LogicalPlan, LogicalPlans, ProjectionKind},
|
|
37
38
|
query_result::QueryResult,
|
|
38
|
-
value::{
|
|
39
|
+
value::{TimeStamp, Value, ValueMap, ValueTryIntoRef, array, value_map},
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
pub use graphcore::{
|
|
42
|
+
pub use graphcore::{Table, table};
|
|
42
43
|
|
|
43
44
|
/// GQLite Result alias. Usable as a standard `Result<T, E>` or default to gqlite::Error with `Result<T>`
|
|
44
45
|
pub type Result<T, E = error::export::Error> = std::result::Result<T, E>;
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
//! Logical planning layer between parsing and bytecode compilation.
|
|
2
|
+
|
|
3
|
+
use crate::Result;
|
|
4
|
+
use gqlparser::oc::ast;
|
|
5
|
+
|
|
6
|
+
/// Ordered list of logical plans.
|
|
7
|
+
pub type LogicalPlans = Vec<LogicalPlan>;
|
|
8
|
+
|
|
9
|
+
/// Logical representation of a statement.
|
|
10
|
+
#[derive(Debug)]
|
|
11
|
+
#[allow(clippy::large_enum_variant)]
|
|
12
|
+
pub enum LogicalPlan
|
|
13
|
+
{
|
|
14
|
+
/// Create a graph.
|
|
15
|
+
CreateGraph
|
|
16
|
+
{
|
|
17
|
+
/// Name of the graph to create.
|
|
18
|
+
name: String,
|
|
19
|
+
/// Whether the operation should be ignored when the graph already exists.
|
|
20
|
+
if_not_exists: bool,
|
|
21
|
+
},
|
|
22
|
+
/// Drop a graph.
|
|
23
|
+
DropGraph
|
|
24
|
+
{
|
|
25
|
+
/// Name of the graph to drop.
|
|
26
|
+
name: String,
|
|
27
|
+
/// Whether the operation should be ignored when the graph does not exist.
|
|
28
|
+
if_exists: bool,
|
|
29
|
+
},
|
|
30
|
+
/// Select the active graph.
|
|
31
|
+
UseGraph
|
|
32
|
+
{
|
|
33
|
+
/// Name of the graph to select.
|
|
34
|
+
name: String,
|
|
35
|
+
},
|
|
36
|
+
/// Create nodes and edges.
|
|
37
|
+
Create
|
|
38
|
+
{
|
|
39
|
+
/// Patterns to create.
|
|
40
|
+
patterns: Vec<ast::Pattern>,
|
|
41
|
+
},
|
|
42
|
+
/// Direct node scan produced from a MATCH clause.
|
|
43
|
+
NodeScan
|
|
44
|
+
{
|
|
45
|
+
/// Patterns to match, including any label constraints present in the AST.
|
|
46
|
+
patterns: Vec<ast::Pattern>,
|
|
47
|
+
/// Whether the scan is optional.
|
|
48
|
+
optional: bool,
|
|
49
|
+
},
|
|
50
|
+
/// Filter rows from another logical operator.
|
|
51
|
+
Filter
|
|
52
|
+
{
|
|
53
|
+
/// Input operator.
|
|
54
|
+
source: Box<LogicalPlan>,
|
|
55
|
+
/// Filter expression.
|
|
56
|
+
expression: ast::Expression,
|
|
57
|
+
},
|
|
58
|
+
/// Project rows for RETURN or WITH.
|
|
59
|
+
Projection
|
|
60
|
+
{
|
|
61
|
+
/// Kind of projection.
|
|
62
|
+
kind: ProjectionKind,
|
|
63
|
+
/// Whether all currently bound variables are projected.
|
|
64
|
+
all: bool,
|
|
65
|
+
/// Explicit expressions to project.
|
|
66
|
+
expressions: Vec<ast::NamedExpression>,
|
|
67
|
+
},
|
|
68
|
+
/// Sort rows from another logical operator.
|
|
69
|
+
Sort
|
|
70
|
+
{
|
|
71
|
+
/// Input operator.
|
|
72
|
+
source: Box<LogicalPlan>,
|
|
73
|
+
/// Sort expressions.
|
|
74
|
+
expressions: Vec<ast::OrderByExpression>,
|
|
75
|
+
},
|
|
76
|
+
/// Skip rows from another logical operator.
|
|
77
|
+
Skip
|
|
78
|
+
{
|
|
79
|
+
/// Input operator.
|
|
80
|
+
source: Box<LogicalPlan>,
|
|
81
|
+
/// Skip expression.
|
|
82
|
+
expression: ast::Expression,
|
|
83
|
+
},
|
|
84
|
+
/// Limit rows from another logical operator.
|
|
85
|
+
Limit
|
|
86
|
+
{
|
|
87
|
+
/// Input operator.
|
|
88
|
+
source: Box<LogicalPlan>,
|
|
89
|
+
/// Limit expression.
|
|
90
|
+
expression: ast::Expression,
|
|
91
|
+
},
|
|
92
|
+
/// Invoke a callable.
|
|
93
|
+
Call
|
|
94
|
+
{
|
|
95
|
+
/// Name of the callable.
|
|
96
|
+
name: String,
|
|
97
|
+
/// Call arguments.
|
|
98
|
+
arguments: Vec<ast::Expression>,
|
|
99
|
+
},
|
|
100
|
+
/// Expand a list into rows.
|
|
101
|
+
Unwind
|
|
102
|
+
{
|
|
103
|
+
/// Variable receiving each value.
|
|
104
|
+
identifier: ast::VariableIdentifier,
|
|
105
|
+
/// Expression producing the input list.
|
|
106
|
+
expression: ast::Expression,
|
|
107
|
+
},
|
|
108
|
+
/// Delete matched entities.
|
|
109
|
+
Delete
|
|
110
|
+
{
|
|
111
|
+
/// Whether connected relationships should also be deleted.
|
|
112
|
+
detach: bool,
|
|
113
|
+
/// Expressions resolving to entities to delete.
|
|
114
|
+
expressions: Vec<ast::Expression>,
|
|
115
|
+
},
|
|
116
|
+
/// Update matched entities.
|
|
117
|
+
Update
|
|
118
|
+
{
|
|
119
|
+
/// Update operations to apply.
|
|
120
|
+
updates: Vec<ast::OneUpdate>,
|
|
121
|
+
},
|
|
122
|
+
/// Merge matched or create entities with conditional updates.
|
|
123
|
+
Merge
|
|
124
|
+
{
|
|
125
|
+
/// Patterns to match or create.
|
|
126
|
+
patterns: Vec<ast::Pattern>,
|
|
127
|
+
/// Updates applied when entities are created.
|
|
128
|
+
on_create: Vec<ast::OneUpdate>,
|
|
129
|
+
/// Updates applied when entities are matched.
|
|
130
|
+
on_match: Vec<ast::OneUpdate>,
|
|
131
|
+
},
|
|
132
|
+
/// Vector similarity search for ranked result retrieval.
|
|
133
|
+
VectorSearch
|
|
134
|
+
{
|
|
135
|
+
/// Name of the vector index.
|
|
136
|
+
index: String,
|
|
137
|
+
/// Query vector.
|
|
138
|
+
query: ast::Expression,
|
|
139
|
+
/// Top-K results to return.
|
|
140
|
+
k: usize,
|
|
141
|
+
/// Variable to bind result nodes to.
|
|
142
|
+
result_var: ast::VariableIdentifier,
|
|
143
|
+
/// Optional variable to bind similarity scores to.
|
|
144
|
+
score_var: Option<ast::VariableIdentifier>,
|
|
145
|
+
},
|
|
146
|
+
/// Create a vector index (schema operation).
|
|
147
|
+
CreateVectorIndex
|
|
148
|
+
{
|
|
149
|
+
/// Index name.
|
|
150
|
+
name: String,
|
|
151
|
+
/// Label name (without colon).
|
|
152
|
+
label: String,
|
|
153
|
+
/// Property name.
|
|
154
|
+
property: String,
|
|
155
|
+
/// Vector dimension.
|
|
156
|
+
dimension: Option<usize>,
|
|
157
|
+
/// Distance metric.
|
|
158
|
+
metric: Option<ast::Metric>,
|
|
159
|
+
/// If not exists
|
|
160
|
+
if_not_exists: bool,
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// Type of projection.
|
|
165
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
166
|
+
pub enum ProjectionKind
|
|
167
|
+
{
|
|
168
|
+
/// Final output projection.
|
|
169
|
+
Return,
|
|
170
|
+
/// Intermediate projection.
|
|
171
|
+
With,
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fn wrap_filter(plan: LogicalPlan, where_expression: Option<ast::Expression>) -> LogicalPlan
|
|
175
|
+
{
|
|
176
|
+
match where_expression
|
|
177
|
+
{
|
|
178
|
+
Some(expression) => LogicalPlan::Filter {
|
|
179
|
+
source: Box::new(plan),
|
|
180
|
+
expression,
|
|
181
|
+
},
|
|
182
|
+
None => plan,
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
fn wrap_modifiers(plan: LogicalPlan, modifiers: ast::Modifiers) -> LogicalPlan
|
|
187
|
+
{
|
|
188
|
+
let mut plan = plan;
|
|
189
|
+
|
|
190
|
+
if let Some(order_by) = modifiers.order_by
|
|
191
|
+
{
|
|
192
|
+
plan = LogicalPlan::Sort {
|
|
193
|
+
source: Box::new(plan),
|
|
194
|
+
expressions: order_by.expressions,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if let Some(skip) = modifiers.skip
|
|
199
|
+
{
|
|
200
|
+
plan = LogicalPlan::Skip {
|
|
201
|
+
source: Box::new(plan),
|
|
202
|
+
expression: skip,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if let Some(limit) = modifiers.limit
|
|
207
|
+
{
|
|
208
|
+
plan = LogicalPlan::Limit {
|
|
209
|
+
source: Box::new(plan),
|
|
210
|
+
expression: limit,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
plan
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fn plan_projection(
|
|
218
|
+
kind: ProjectionKind,
|
|
219
|
+
all: bool,
|
|
220
|
+
expressions: Vec<ast::NamedExpression>,
|
|
221
|
+
modifiers: ast::Modifiers,
|
|
222
|
+
where_expression: Option<ast::Expression>,
|
|
223
|
+
) -> LogicalPlan
|
|
224
|
+
{
|
|
225
|
+
let plan = LogicalPlan::Projection {
|
|
226
|
+
kind,
|
|
227
|
+
all,
|
|
228
|
+
expressions,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
wrap_modifiers(wrap_filter(plan, where_expression), modifiers)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/// Build a logical plan for a single parsed statement.
|
|
235
|
+
pub fn plan(statement: ast::Statement) -> Result<LogicalPlan>
|
|
236
|
+
{
|
|
237
|
+
plan_impl(statement)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
fn plan_impl(statement: ast::Statement) -> Result<LogicalPlan>
|
|
241
|
+
{
|
|
242
|
+
match statement
|
|
243
|
+
{
|
|
244
|
+
ast::Statement::CreateGraph(create_graph) => Ok(LogicalPlan::CreateGraph {
|
|
245
|
+
name: create_graph.name,
|
|
246
|
+
if_not_exists: create_graph.if_not_exists,
|
|
247
|
+
}),
|
|
248
|
+
ast::Statement::DropGraph(drop_graph) => Ok(LogicalPlan::DropGraph {
|
|
249
|
+
name: drop_graph.name,
|
|
250
|
+
if_exists: drop_graph.if_exists,
|
|
251
|
+
}),
|
|
252
|
+
ast::Statement::UseGraph(use_graph) => Ok(LogicalPlan::UseGraph {
|
|
253
|
+
name: use_graph.name,
|
|
254
|
+
}),
|
|
255
|
+
ast::Statement::Create(create) => Ok(LogicalPlan::Create {
|
|
256
|
+
patterns: create.patterns,
|
|
257
|
+
}),
|
|
258
|
+
ast::Statement::Match(match_statement) =>
|
|
259
|
+
{
|
|
260
|
+
// If SEARCH clause exists, emit VectorSearch instead of NodeScan
|
|
261
|
+
if let Some(search) = match_statement.search
|
|
262
|
+
{
|
|
263
|
+
Ok(wrap_filter(
|
|
264
|
+
LogicalPlan::VectorSearch {
|
|
265
|
+
index: search.index,
|
|
266
|
+
query: search.query,
|
|
267
|
+
k: search.limit,
|
|
268
|
+
result_var: search.variable,
|
|
269
|
+
score_var: search.score_alias,
|
|
270
|
+
},
|
|
271
|
+
match_statement.where_expression,
|
|
272
|
+
))
|
|
273
|
+
}
|
|
274
|
+
else
|
|
275
|
+
{
|
|
276
|
+
// Standard node scan when no SEARCH
|
|
277
|
+
Ok(wrap_filter(
|
|
278
|
+
LogicalPlan::NodeScan {
|
|
279
|
+
patterns: match_statement.patterns,
|
|
280
|
+
optional: match_statement.optional,
|
|
281
|
+
},
|
|
282
|
+
match_statement.where_expression,
|
|
283
|
+
))
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
ast::Statement::Return(return_statement) => Ok(plan_projection(
|
|
287
|
+
ProjectionKind::Return,
|
|
288
|
+
return_statement.all,
|
|
289
|
+
return_statement.expressions,
|
|
290
|
+
return_statement.modifiers,
|
|
291
|
+
return_statement.where_expression,
|
|
292
|
+
)),
|
|
293
|
+
ast::Statement::Call(call) => Ok(LogicalPlan::Call {
|
|
294
|
+
name: call.name,
|
|
295
|
+
arguments: call.arguments,
|
|
296
|
+
}),
|
|
297
|
+
ast::Statement::With(with) => Ok(plan_projection(
|
|
298
|
+
ProjectionKind::With,
|
|
299
|
+
with.all,
|
|
300
|
+
with.expressions,
|
|
301
|
+
with.modifiers,
|
|
302
|
+
with.where_expression,
|
|
303
|
+
)),
|
|
304
|
+
ast::Statement::Unwind(unwind) => Ok(LogicalPlan::Unwind {
|
|
305
|
+
identifier: unwind.identifier,
|
|
306
|
+
expression: unwind.expression,
|
|
307
|
+
}),
|
|
308
|
+
ast::Statement::Delete(delete_statement) => Ok(LogicalPlan::Delete {
|
|
309
|
+
detach: delete_statement.detach,
|
|
310
|
+
expressions: delete_statement.expressions,
|
|
311
|
+
}),
|
|
312
|
+
ast::Statement::Update(update_statement) => Ok(LogicalPlan::Update {
|
|
313
|
+
updates: update_statement.updates,
|
|
314
|
+
}),
|
|
315
|
+
ast::Statement::Merge(merge_statement) => Ok(LogicalPlan::Merge {
|
|
316
|
+
patterns: merge_statement.patterns,
|
|
317
|
+
on_create: merge_statement.on_create,
|
|
318
|
+
on_match: merge_statement.on_match,
|
|
319
|
+
}),
|
|
320
|
+
ast::Statement::CreateVectorIndex(create_vector_index) => Ok(LogicalPlan::CreateVectorIndex {
|
|
321
|
+
name: create_vector_index.name,
|
|
322
|
+
label: create_vector_index.label,
|
|
323
|
+
property: create_vector_index.property,
|
|
324
|
+
dimension: create_vector_index.dimension,
|
|
325
|
+
metric: create_vector_index.metric,
|
|
326
|
+
if_not_exists: create_vector_index.if_not_exists,
|
|
327
|
+
}),
|
|
328
|
+
}
|
|
329
|
+
}
|
data/ext/gqlitedb/src/prelude.rs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
pub(crate) use crate::{
|
|
2
|
-
aggregators, compiler, consts,
|
|
2
|
+
Error, Result, aggregators, compiler, consts,
|
|
3
3
|
error::{self, CompileTimeError, InternalError, RunTimeError, StoreError},
|
|
4
|
-
functions, graph, interpreter,
|
|
4
|
+
functions, graph, interpreter, query_result, store, utils, value,
|
|
5
5
|
value::ValueExt as _,
|
|
6
|
-
value_table,
|
|
6
|
+
value_table,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
pub(crate) use error::export::Error as ErrorType;
|