MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / render_plan_expr

Method render_plan_expr

src/compute/src/render.rs:1148–1386  ·  view source on GitHub ↗

Renders a [`render_plan::Expr`], producing the collection of results. # Panics Panics if any of the expr's inputs is not found in `collections`. Callers must ensure that input nodes have been rendered previously.

(
        &self,
        expr: render_plan::Expr,
        collections: &BTreeMap<LirId, CollectionBundle<'scope, T>>,
    )

Source from the content-addressed store, hash-verified

1146 /// Panics if any of the expr's inputs is not found in `collections`.
1147 /// Callers must ensure that input nodes have been rendered previously.
1148 fn render_plan_expr(
1149 &self,
1150 expr: render_plan::Expr,
1151 collections: &BTreeMap<LirId, CollectionBundle<'scope, T>>,
1152 ) -> CollectionBundle<'scope, T> {
1153 use render_plan::Expr::*;
1154
1155 let expect_input = |id| {
1156 collections
1157 .get(&id)
1158 .cloned()
1159 .unwrap_or_else(|| panic!("missing input collection: {id}"))
1160 };
1161
1162 match expr {
1163 Constant { rows } => {
1164 // Produce both rows and errs to avoid conditional dataflow construction.
1165 let (rows, errs) = match rows {
1166 Ok(rows) => (rows, Vec::new()),
1167 Err(e) => (Vec::new(), vec![e]),
1168 };
1169
1170 // We should advance times in constant collections to start from `as_of`.
1171 let as_of_frontier = self.as_of_frontier.clone();
1172 let until = self.until.clone();
1173 let ok_collection = rows
1174 .into_iter()
1175 .filter_map(move |(row, mut time, diff)| {
1176 time.advance_by(as_of_frontier.borrow());
1177 if !until.less_equal(&time) {
1178 Some((
1179 row,
1180 <T as Refines<mz_repr::Timestamp>>::to_inner(time),
1181 diff,
1182 ))
1183 } else {
1184 None
1185 }
1186 })
1187 .to_stream(self.scope)
1188 .as_collection();
1189
1190 let mut error_time: mz_repr::Timestamp = Timestamp::minimum();
1191 error_time.advance_by(self.as_of_frontier.borrow());
1192 let err_collection = errs
1193 .into_iter()
1194 .map(move |e| {
1195 (
1196 DataflowErrorSer::from(e),
1197 <T as Refines<mz_repr::Timestamp>>::to_inner(error_time),
1198 Diff::ONE,
1199 )
1200 })
1201 .to_stream(self.scope)
1202 .as_collection();
1203
1204 CollectionBundle::from_collections(ok_collection, err_collection)
1205 }

Callers 1

render_letfree_planMethod · 0.80

Calls 15

as_collectionMethod · 0.80
lookup_idMethod · 0.80
anyMethod · 0.80
as_collection_coreMethod · 0.80
render_flat_mapMethod · 0.80
render_joinMethod · 0.80
render_delta_joinMethod · 0.80
render_reduceMethod · 0.80
render_topkMethod · 0.80
render_thresholdMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected