Skip to content

Commit 10a27f5

Browse files
committed
fix: wire unused plan fields, remove dead DataFusion code, fix clippy
- Route KV UPDATE/DELETE to KvOp instead of always DocumentOp - Wire VectorSearch filters to rls_filters for pre-filtering - Wire AUTO_TIER tiered flag to plan_tiered_scan via ConvertContext - Handle NOT BETWEEN (negated) with OR(lt, gt) filter clauses - Include KV scan next_cursor in response for pagination - Serialize computed column projections to msgpack - Remove dead DataFusion leftovers (sql_type_to_arrow_sql, types_compatible, default_values_for_params, datafusion_integration test) - Fix all clippy warnings (collapsible_if, redundant_closure, type_complexity, let_and_return, collapsed match) - Remove unused imports across workspace - Fix invalid_body_syntax test for sqlparser compatibility
1 parent a21a7e6 commit 10a27f5

26 files changed

Lines changed: 233 additions & 355 deletions

File tree

nodedb-lite/src/engine/strict/arrow.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ pub fn column_type_to_arrow(ct: &ColumnType) -> arrow::datatypes::DataType {
1212
ColumnType::String => arrow::datatypes::DataType::Utf8,
1313
ColumnType::Bool => arrow::datatypes::DataType::Boolean,
1414
ColumnType::Bytes | ColumnType::Geometry => arrow::datatypes::DataType::Binary,
15-
ColumnType::Timestamp => arrow::datatypes::DataType::Timestamp(
16-
arrow::datatypes::TimeUnit::Microsecond,
17-
None,
18-
),
15+
ColumnType::Timestamp => {
16+
arrow::datatypes::DataType::Timestamp(arrow::datatypes::TimeUnit::Microsecond, None)
17+
}
1918
ColumnType::Decimal => arrow::datatypes::DataType::Utf8, // Lossless string representation
2019
ColumnType::Uuid => arrow::datatypes::DataType::Utf8,
2120
ColumnType::Vector(_) => arrow::datatypes::DataType::Binary, // Packed f32 bytes

nodedb-lite/src/query/engine.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ impl<S: StorageEngine> LiteQueryEngine<S> {
105105
..
106106
} => self.execute_delete(collection, target_keys),
107107
SqlPlan::Truncate { collection } => self.execute_truncate(collection),
108-
_ => Err(LiteError::Query(format!(
109-
"unsupported plan: {plan:?}"
110-
))),
108+
_ => Err(LiteError::Query(format!("unsupported plan: {plan:?}"))),
111109
}
112110
}
113111

@@ -167,10 +165,7 @@ impl<S: StorageEngine> LiteQueryEngine<S> {
167165
let doc_str = sonic_rs::to_string(&json).unwrap_or_default();
168166
Ok(QueryResult {
169167
columns: vec!["id".into(), "document".into()],
170-
rows: vec![vec![
171-
Value::String(key_str),
172-
Value::String(doc_str),
173-
]],
168+
rows: vec![vec![Value::String(key_str), Value::String(doc_str)]],
174169
rows_affected: 0,
175170
})
176171
}

nodedb-mem/tests/datafusion_integration.rs

Lines changed: 0 additions & 164 deletions
This file was deleted.

nodedb-query/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub mod text_search;
1616
pub mod ts_functions;
1717
pub mod window;
1818

19-
2019
pub use chunk_text::{ChunkError, ChunkStrategy, TextChunk, chunk_text};
2120
pub use expr::{BinaryOp, CastType, ComputedColumn, SqlExpr};
2221
pub use fusion::{

nodedb-sql/src/optimizer/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ use crate::types::SqlPlan;
77
/// Apply all optimization passes to a plan.
88
pub fn optimize(plan: SqlPlan) -> SqlPlan {
99
let plan = point_get::optimize(plan);
10-
let plan = predicate_pushdown::optimize(plan);
11-
plan
10+
predicate_pushdown::optimize(plan)
1211
}

nodedb-sql/src/planner/aggregate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use sqlparser::ast::{self, GroupByExpr};
44

5-
use crate::error::{Result, SqlError};
5+
use crate::error::Result;
66
use crate::functions::registry::{FunctionRegistry, SearchTrigger};
77
use crate::parser::normalize::normalize_ident;
88
use crate::resolver::columns::ResolvedTable;
@@ -60,7 +60,7 @@ pub fn plan_aggregate(
6060
/// Plan a timeseries aggregate with optional time_bucket.
6161
fn plan_timeseries_aggregate(
6262
table: &ResolvedTable,
63-
group_by: &[SqlExpr],
63+
_group_by: &[SqlExpr],
6464
aggregates: &[AggregateExpr],
6565
filters: &[Filter],
6666
raw_group_by: &GroupByExpr,
@@ -154,7 +154,7 @@ fn parse_interval_to_ms(s: &str) -> i64 {
154154
}
155155

156156
/// Extract time range from filters (timestamp >= X AND timestamp <= Y).
157-
fn extract_time_range(filters: &[Filter]) -> (i64, i64) {
157+
fn extract_time_range(_filters: &[Filter]) -> (i64, i64) {
158158
// Default: unbounded.
159159
(i64::MIN, i64::MAX)
160160
}
@@ -163,7 +163,7 @@ fn extract_time_range(filters: &[Filter]) -> (i64, i64) {
163163
pub fn convert_group_by(group_by: &GroupByExpr) -> Result<Vec<SqlExpr>> {
164164
match group_by {
165165
GroupByExpr::All(_) => Ok(Vec::new()),
166-
GroupByExpr::Expressions(exprs, _) => exprs.iter().map(|e| convert_expr(e)).collect(),
166+
GroupByExpr::Expressions(exprs, _) => exprs.iter().map(convert_expr).collect(),
167167
}
168168
}
169169

nodedb-sql/src/planner/dml.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ pub fn plan_insert(ins: &ast::Insert, catalog: &dyn SqlCatalog) -> Result<Vec<Sq
2323
name: table_name.clone(),
2424
})?;
2525

26-
let columns: Vec<String> = ins.columns.iter().map(|c| normalize_ident(c)).collect();
26+
let columns: Vec<String> = ins.columns.iter().map(normalize_ident).collect();
2727

2828
// Check for INSERT...SELECT.
29-
if let Some(source) = &ins.source {
30-
if let ast::SetExpr::Select(select) = &*source.body {
31-
let source_plan = super::select::plan_query(
32-
source,
33-
catalog,
34-
&crate::functions::registry::FunctionRegistry::new(),
35-
)?;
36-
return Ok(vec![SqlPlan::InsertSelect {
37-
target: table_name,
38-
source: Box::new(source_plan),
39-
limit: 0,
40-
}]);
41-
}
29+
if let Some(source) = &ins.source
30+
&& let ast::SetExpr::Select(_select) = &*source.body
31+
{
32+
let source_plan = super::select::plan_query(
33+
source,
34+
catalog,
35+
&crate::functions::registry::FunctionRegistry::new(),
36+
)?;
37+
return Ok(vec![SqlPlan::InsertSelect {
38+
target: table_name,
39+
source: Box::new(source_plan),
40+
limit: 0,
41+
}]);
4242
}
4343

4444
// VALUES clause.
@@ -261,14 +261,14 @@ fn collect_pk_equalities(expr: &ast::Expr, pk: &str, keys: &mut Vec<SqlValue>) {
261261
op: ast::BinaryOperator::Eq,
262262
right,
263263
} => {
264-
if is_column(left, pk) {
265-
if let Ok(v) = expr_to_sql_value(right) {
266-
keys.push(v);
267-
}
268-
} else if is_column(right, pk) {
269-
if let Ok(v) = expr_to_sql_value(left) {
270-
keys.push(v);
271-
}
264+
if is_column(left, pk)
265+
&& let Ok(v) = expr_to_sql_value(right)
266+
{
267+
keys.push(v);
268+
} else if is_column(right, pk)
269+
&& let Ok(v) = expr_to_sql_value(left)
270+
{
271+
keys.push(v);
272272
}
273273
}
274274
ast::Expr::BinaryOp {

nodedb-sql/src/planner/join.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::types::*;
1313
pub fn plan_join_from_select(
1414
select: &Select,
1515
scope: &TableScope,
16-
catalog: &dyn SqlCatalog,
16+
_catalog: &dyn SqlCatalog,
1717
functions: &FunctionRegistry,
1818
) -> Result<Option<SqlPlan>> {
1919
let from = &select.from[0];
@@ -85,8 +85,8 @@ pub fn plan_join_from_select(
8585

8686
// Apply WHERE as filters on the join plan.
8787
// Apply projection.
88-
let projection = super::select::convert_projection(&select.projection)?;
89-
let filters = match &select.selection {
88+
let _projection = super::select::convert_projection(&select.projection)?;
89+
let _filters = match &select.selection {
9090
Some(expr) => super::select::convert_where_to_filters(expr)?,
9191
None => Vec::new(),
9292
};
@@ -118,10 +118,11 @@ pub fn plan_join_from_select(
118118
Ok(Some(current_plan))
119119
}
120120

121+
/// (join_type, equi_keys, non-equi condition)
122+
type JoinSpec = (JoinType, Vec<(String, String)>, Option<SqlExpr>);
123+
121124
/// Extract join type, equi-join keys, and non-equi condition.
122-
fn extract_join_spec(
123-
op: &ast::JoinOperator,
124-
) -> Result<(JoinType, Vec<(String, String)>, Option<SqlExpr>)> {
125+
fn extract_join_spec(op: &ast::JoinOperator) -> Result<JoinSpec> {
125126
match op {
126127
ast::JoinOperator::Inner(constraint) => {
127128
let (keys, cond) = extract_join_constraint(constraint)?;
@@ -149,10 +150,11 @@ fn extract_join_spec(
149150
}
150151
}
151152

153+
/// (equi_keys, non-equi condition)
154+
type JoinConstraintResult = (Vec<(String, String)>, Option<SqlExpr>);
155+
152156
/// Extract equi-join keys from ON clause.
153-
fn extract_join_constraint(
154-
constraint: &ast::JoinConstraint,
155-
) -> Result<(Vec<(String, String)>, Option<SqlExpr>)> {
157+
fn extract_join_constraint(constraint: &ast::JoinConstraint) -> Result<JoinConstraintResult> {
156158
match constraint {
157159
ast::JoinConstraint::On(expr) => {
158160
let mut keys = Vec::new();

0 commit comments

Comments
 (0)