Skip to content

Commit 08c51ed

Browse files
committed
feat: add projection/filters to SqlPlan::Join and post_dedup to PhysicalTask
SqlPlan::Join now carries post-join projection and filter fields so the planner can propagate SELECT column lists and WHERE predicates through join plans rather than discarding them. PhysicalTask gains a post_dedup flag used by the router to trigger UNION DISTINCT row deduplication after collecting responses from all sub-query tasks. QueryOp::HashJoin picks up matching projection and post_filters fields for the Data Plane executor.
1 parent 54d2262 commit 08c51ed

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

nodedb-sql/src/planner/select.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ fn plan_select(
126126
join_type: sq.join_type,
127127
condition: None,
128128
limit: 10000,
129+
projection: Vec::new(),
130+
filters: Vec::new(),
129131
};
130132
}
131133
return Ok(plan);
@@ -159,6 +161,8 @@ fn plan_select(
159161
join_type: sq.join_type,
160162
condition: None,
161163
limit: 10000,
164+
projection: Vec::new(),
165+
filters: Vec::new(),
162166
};
163167
}
164168

nodedb-sql/src/types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ pub enum SqlPlan {
7777
join_type: JoinType,
7878
condition: Option<SqlExpr>,
7979
limit: usize,
80+
/// Post-join projection: column names to keep (empty = all columns).
81+
projection: Vec<Projection>,
82+
/// Post-join filters (from WHERE clause).
83+
filters: Vec<Filter>,
8084
},
8185

8286
// ── Aggregation ──

nodedb/src/bridge/physical_plan/query.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ pub enum QueryOp {
3535
post_group_by: Vec<String>,
3636
/// Post-join aggregates: (op, field) pairs (empty = no aggregation).
3737
post_aggregates: Vec<(String, String)>,
38+
/// Post-join projection: column names to keep (empty = all).
39+
projection: Vec<String>,
40+
/// Post-join WHERE filter predicates (MessagePack).
41+
post_filters: Vec<u8>,
3842
},
3943

4044
/// Broadcast join: small side serialized in the plan.

nodedb/src/control/planner/physical.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ pub struct PhysicalTask {
1515

1616
/// The physical operation to execute.
1717
pub plan: PhysicalPlan,
18+
19+
/// When true, results from this task batch must be deduplicated
20+
/// (e.g. UNION DISTINCT across multiple sub-queries).
21+
pub post_dedup: bool,
1822
}

0 commit comments

Comments
 (0)