@@ -92,6 +92,46 @@ pub enum QueryOp {
9292 distinct : bool ,
9393 } ,
9494
95+ /// Relational post-processing over a materialized child plan.
96+ ///
97+ /// Coordinator-resolved, exactly like [`QueryOp::Exchange`]: at resolve time
98+ /// the coordinator gathers `input`'s rows, flattens them to the relational
99+ /// row shape, and rewrites this node into a [`QueryOp::ProviderScan`]
100+ /// carrying the same relational parameters — which applies
101+ /// filter→offset→sort→distinct→project→limit on a single core. A Data-Plane
102+ /// core must NEVER see this node (defensive error if it does).
103+ ///
104+ /// Lowered from `SqlPlan::Subquery`: an outer `ORDER BY` / `OFFSET` /
105+ /// `DISTINCT` / post-reorder `LIMIT` over a subquery/derived-table body
106+ /// whose leaf plan could not absorb those constraints. Constraints the leaf
107+ /// DID absorb (a `WHERE` pushed into a search engine, an unordered `LIMIT`
108+ /// folded into `top_k`) are applied by `input` and not repeated here.
109+ PostProcess {
110+ /// The subquery body to materialize. Wrapped in `Exchange{Gather}` by
111+ /// the converter when the body is a sharded source, so the gather runs
112+ /// exactly once over the full union before post-processing.
113+ input : Box < crate :: physical_plan:: PhysicalPlan > ,
114+ /// Serialized `Vec<ScanFilter>` (MessagePack). Empty = no predicate.
115+ #[ serde( default ) ]
116+ filters : Vec < u8 > ,
117+ /// Output column names to keep. Empty = emit all columns.
118+ #[ serde( default ) ]
119+ projection : Vec < String > ,
120+ /// Sort keys: `(column_name, ascending)`. Empty = unordered.
121+ #[ serde( default ) ]
122+ sort_keys : Vec < ( String , bool ) > ,
123+ /// Maximum rows to emit after offset/sort/distinct/projection.
124+ /// `None` = unlimited.
125+ #[ serde( default ) ]
126+ limit : Option < usize > ,
127+ /// Number of rows to skip before applying limit.
128+ #[ serde( default ) ]
129+ offset : usize ,
130+ /// SQL DISTINCT: deduplicate on the projected row.
131+ #[ serde( default ) ]
132+ distinct : bool ,
133+ } ,
134+
95135 /// Aggregate: GROUP BY + aggregate functions.
96136 Aggregate {
97137 collection : String ,
0 commit comments