Skip to content

Commit 27f0297

Browse files
committed
code fmt
1 parent 47f1012 commit 27f0297

5 files changed

Lines changed: 52 additions & 66 deletions

File tree

src/query_planner/logical_expr/ast_conversion.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,12 @@ impl<'a> TryFrom<open_cypher_parser::ast::PathPattern<'a>> for PathPattern {
204204
.collect::<Result<Vec<_>, _>>()?;
205205
Ok(PathPattern::ConnectedPattern(connected_patterns))
206206
}
207-
open_cypher_parser::ast::PathPattern::ShortestPath(inner) => {
208-
Ok(PathPattern::ShortestPath(Box::new(PathPattern::try_from(
209-
*inner,
210-
)?)))
211-
}
212-
open_cypher_parser::ast::PathPattern::AllShortestPaths(inner) => {
213-
Ok(PathPattern::AllShortestPaths(Box::new(
214-
PathPattern::try_from(*inner)?,
215-
)))
216-
}
207+
open_cypher_parser::ast::PathPattern::ShortestPath(inner) => Ok(
208+
PathPattern::ShortestPath(Box::new(PathPattern::try_from(*inner)?)),
209+
),
210+
open_cypher_parser::ast::PathPattern::AllShortestPaths(inner) => Ok(
211+
PathPattern::AllShortestPaths(Box::new(PathPattern::try_from(*inner)?)),
212+
),
217213
}
218214
}
219215
}
@@ -477,11 +473,9 @@ impl<'a> std::convert::TryFrom<open_cypher_parser::ast::Expression<'a>> for Logi
477473
)),
478474
Expression::PathPattern(pp) => Ok(LogicalExpr::PathPattern(PathPattern::try_from(pp)?)),
479475
Expression::Case(case) => Ok(LogicalExpr::Case(LogicalCase::try_from(case)?)),
480-
Expression::ExistsExpression(exists) => {
481-
Ok(LogicalExpr::ExistsSubquery(ExistsSubquery::try_from(
482-
*exists,
483-
)?))
484-
}
476+
Expression::ExistsExpression(exists) => Ok(LogicalExpr::ExistsSubquery(
477+
ExistsSubquery::try_from(*exists)?,
478+
)),
485479
Expression::ReduceExp(reduce) => Ok(LogicalExpr::ReduceExpr(ReduceExpr {
486480
accumulator: reduce.accumulator.to_string(),
487481
initial_value: Box::new(Self::try_from(*reduce.initial_value)?),

src/query_planner/logical_expr/combinators.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ pub fn is_comparison(expr: &LogicalExpr) -> bool {
7373
/// `(a AND (b AND c))` → `[a, b, c]`
7474
pub fn flatten_boolean_op(expr: &LogicalExpr, op: Operator) -> Vec<LogicalExpr> {
7575
match expr {
76-
LogicalExpr::OperatorApplicationExp(op_app) if op_app.operator == op => {
77-
op_app
78-
.operands
79-
.iter()
80-
.flat_map(|operand| flatten_boolean_op(operand, op))
81-
.collect()
82-
}
76+
LogicalExpr::OperatorApplicationExp(op_app) if op_app.operator == op => op_app
77+
.operands
78+
.iter()
79+
.flat_map(|operand| flatten_boolean_op(operand, op))
80+
.collect(),
8381
other => vec![other.clone()],
8482
}
8583
}

src/query_planner/logical_expr/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub mod errors;
3030
pub mod expression_rewriter;
3131
pub mod visitors;
3232

33-
3433
/// Type of graph entity (node or relationship).
3534
/// Used in CteEntityRef to indicate what kind of entity is being referenced.
3635
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
@@ -438,7 +437,6 @@ pub struct RelationshipPattern {
438437
pub properties: Option<Vec<Property>>,
439438
}
440439

441-
442440
// =============================================================================
443441
// Display Implementations
444442
// =============================================================================
@@ -920,7 +918,7 @@ impl LogicalExpr {
920918
#[test]
921919
fn test_pattern_comprehension_error_instead_of_panic() {
922920
use crate::open_cypher_parser;
923-
921+
924922
// Test that PatternComprehension now returns an error instead of panicking
925923
let pattern_comprehension = open_cypher_parser::ast::Expression::PatternComprehension(
926924
open_cypher_parser::ast::PatternComprehension {

src/query_planner/logical_expr/visitors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ impl ExpressionVisitor for PropertyAccessCollector {
251251
fn visit_property_access(&mut self, prop: &PropertyAccess) {
252252
let property_name = match &prop.column {
253253
crate::graph_catalog::expression_parser::PropertyValue::Column(col) => col.clone(),
254-
crate::graph_catalog::expression_parser::PropertyValue::Expression(expr) => expr.clone(),
254+
crate::graph_catalog::expression_parser::PropertyValue::Expression(expr) => {
255+
expr.clone()
256+
}
255257
};
256258
self.properties
257259
.push((prop.table_alias.0.clone(), property_name));

src/query_planner/plan_ctx/builder.rs

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ use std::{
2222
use crate::{
2323
graph_catalog::{graph_schema::GraphSchema, pattern_schema::PatternSchemaContext},
2424
query_planner::{
25-
analyzer::property_requirements::PropertyRequirements,
26-
join_context::VlpEndpointInfo,
27-
logical_plan::ProjectionItem,
28-
typed_variable::VariableRegistry,
25+
analyzer::property_requirements::PropertyRequirements, join_context::VlpEndpointInfo,
26+
logical_plan::ProjectionItem, typed_variable::VariableRegistry,
2927
},
3028
};
3129

@@ -37,14 +35,14 @@ use super::{PlanCtx, TableCtx};
3735
pub struct PlanCtxBuilder {
3836
// Required
3937
schema: Arc<GraphSchema>,
40-
38+
4139
// Optional with defaults
4240
tenant_id: Option<String>,
4341
view_parameter_values: Option<HashMap<String, String>>,
4442
max_inferred_types: usize,
4543
parent_scope: Option<Box<PlanCtx>>,
4644
is_with_scope: bool,
47-
45+
4846
// Internal state (typically defaults)
4947
alias_table_ctx_map: HashMap<String, TableCtx>,
5048
optional_aliases: HashSet<String>,
@@ -80,7 +78,7 @@ impl PlanCtxBuilder {
8078
cte_alias_sources: HashMap::new(),
8179
}
8280
}
83-
81+
8482
/// Create a builder from a parent scope (for WITH clause scoping).
8583
/// Inherits schema, tenant_id, view_parameters, and vlp_endpoints.
8684
pub fn from_parent(parent: &PlanCtx, is_with_scope: bool) -> Self {
@@ -103,85 +101,85 @@ impl PlanCtxBuilder {
103101
cte_alias_sources: HashMap::new(),
104102
}
105103
}
106-
104+
107105
/// Set the tenant ID for multi-tenant deployments.
108106
pub fn tenant_id(mut self, tenant_id: impl Into<String>) -> Self {
109107
self.tenant_id = Some(tenant_id.into());
110108
self
111109
}
112-
110+
113111
/// Set the tenant ID optionally.
114112
pub fn tenant_id_opt(mut self, tenant_id: Option<String>) -> Self {
115113
self.tenant_id = tenant_id;
116114
self
117115
}
118-
116+
119117
/// Set view parameter values for parameterized views.
120118
pub fn view_parameters(mut self, params: HashMap<String, String>) -> Self {
121119
self.view_parameter_values = Some(params);
122120
self
123121
}
124-
122+
125123
/// Set view parameter values optionally.
126124
pub fn view_parameters_opt(mut self, params: Option<HashMap<String, String>>) -> Self {
127125
self.view_parameter_values = params;
128126
self
129127
}
130-
128+
131129
/// Set maximum number of inferred edge types.
132130
pub fn max_inferred_types(mut self, max: usize) -> Self {
133131
self.max_inferred_types = max;
134132
self
135133
}
136-
134+
137135
/// Mark this scope as a WITH scope (barrier for variable lookup).
138136
pub fn as_with_scope(mut self) -> Self {
139137
self.is_with_scope = true;
140138
self
141139
}
142-
140+
143141
/// Set the parent scope explicitly.
144142
pub fn parent_scope(mut self, parent: PlanCtx) -> Self {
145143
self.parent_scope = Some(Box::new(parent));
146144
self
147145
}
148-
146+
149147
/// Initialize with existing table contexts.
150148
pub fn with_table_contexts(mut self, contexts: HashMap<String, TableCtx>) -> Self {
151149
self.alias_table_ctx_map = contexts;
152150
self
153151
}
154-
152+
155153
/// Initialize with existing optional aliases.
156154
pub fn with_optional_aliases(mut self, aliases: HashSet<String>) -> Self {
157155
self.optional_aliases = aliases;
158156
self
159157
}
160-
158+
161159
/// Set the CTE counter (for generating unique CTE names).
162160
pub fn cte_counter(mut self, counter: usize) -> Self {
163161
self.cte_counter = counter;
164162
self
165163
}
166-
164+
167165
/// Set property requirements.
168166
pub fn property_requirements(mut self, requirements: PropertyRequirements) -> Self {
169167
self.property_requirements = Some(requirements);
170168
self
171169
}
172-
170+
173171
/// Set VLP endpoints.
174172
pub fn vlp_endpoints(mut self, endpoints: HashMap<String, VlpEndpointInfo>) -> Self {
175173
self.vlp_endpoints = endpoints;
176174
self
177175
}
178-
176+
179177
/// Set the variable registry.
180178
pub fn variables(mut self, registry: VariableRegistry) -> Self {
181179
self.variables = registry;
182180
self
183181
}
184-
182+
185183
/// Build the PlanCtx instance.
186184
pub fn build(self) -> PlanCtx {
187185
PlanCtx {
@@ -211,7 +209,7 @@ impl PlanCtxBuilder {
211209
#[cfg(test)]
212210
mod tests {
213211
use super::*;
214-
212+
215213
fn make_test_schema() -> Arc<GraphSchema> {
216214
Arc::new(GraphSchema::build(
217215
1,
@@ -220,67 +218,63 @@ mod tests {
220218
HashMap::new(),
221219
))
222220
}
223-
221+
224222
#[test]
225223
fn test_builder_minimal() {
226224
let schema = make_test_schema();
227225
let ctx = PlanCtxBuilder::new(schema.clone()).build();
228-
226+
229227
assert_eq!(ctx.schema().database(), "test");
230228
assert!(ctx.tenant_id.is_none());
231229
assert_eq!(ctx.max_inferred_types, 5);
232230
}
233-
231+
234232
#[test]
235233
fn test_builder_with_tenant() {
236234
let schema = make_test_schema();
237-
let ctx = PlanCtxBuilder::new(schema)
238-
.tenant_id("tenant-123")
239-
.build();
240-
235+
let ctx = PlanCtxBuilder::new(schema).tenant_id("tenant-123").build();
236+
241237
assert_eq!(ctx.tenant_id, Some("tenant-123".to_string()));
242238
}
243-
239+
244240
#[test]
245241
fn test_builder_with_all_params() {
246242
let schema = make_test_schema();
247243
let mut params = HashMap::new();
248244
params.insert("region".to_string(), "US".to_string());
249-
245+
250246
let ctx = PlanCtxBuilder::new(schema)
251247
.tenant_id("tenant-123")
252248
.view_parameters(params.clone())
253249
.max_inferred_types(10)
254250
.build();
255-
251+
256252
assert_eq!(ctx.tenant_id, Some("tenant-123".to_string()));
257253
assert_eq!(ctx.view_parameter_values, Some(params));
258254
assert_eq!(ctx.max_inferred_types, 10);
259255
}
260-
256+
261257
#[test]
262258
fn test_builder_from_parent() {
263259
let schema = make_test_schema();
264260
let parent = PlanCtxBuilder::new(schema.clone())
265261
.tenant_id("parent-tenant")
266262
.max_inferred_types(15)
267263
.build();
268-
264+
269265
let child = PlanCtxBuilder::from_parent(&parent, true).build();
270-
266+
271267
assert_eq!(child.tenant_id, Some("parent-tenant".to_string()));
272268
assert_eq!(child.max_inferred_types, 15);
273269
assert!(child.is_with_scope);
274270
assert!(child.parent_scope.is_some());
275271
}
276-
272+
277273
#[test]
278274
fn test_builder_as_with_scope() {
279275
let schema = make_test_schema();
280-
let ctx = PlanCtxBuilder::new(schema)
281-
.as_with_scope()
282-
.build();
283-
276+
let ctx = PlanCtxBuilder::new(schema).as_with_scope().build();
277+
284278
assert!(ctx.is_with_scope);
285279
}
286280
}

0 commit comments

Comments
 (0)