(&mut self, plan: SubscribePlan)
| 171 | type To = GlobalMirPlan<Unresolved>; |
| 172 | |
| 173 | fn optimize(&mut self, plan: SubscribePlan) -> Result<Self::To, OptimizerError> { |
| 174 | let output = plan.output; |
| 175 | let plan = plan.from; |
| 176 | let time = Instant::now(); |
| 177 | |
| 178 | let mut df_builder = { |
| 179 | let compute = self.compute_instance.clone(); |
| 180 | DataflowBuilder::new(&*self.catalog, compute).with_config(&self.config) |
| 181 | }; |
| 182 | let mut df_desc = MirDataflowDescription::new(self.debug_name.clone()); |
| 183 | let mut df_meta = DataflowMetainfo::default(); |
| 184 | |
| 185 | match plan { |
| 186 | SubscribeFrom::Id(from_id) => { |
| 187 | let from = self.catalog.get_entry(&from_id); |
| 188 | let from_desc = from |
| 189 | .relation_desc() |
| 190 | .expect("subscribes can only be run on items with descs") |
| 191 | .into_owned(); |
| 192 | |
| 193 | df_builder.import_into_dataflow(&from_id, &mut df_desc, &self.config.features)?; |
| 194 | df_builder.maybe_reoptimize_imported_views(&mut df_desc, &self.config)?; |
| 195 | |
| 196 | // Make SinkDesc |
| 197 | let sink_description = ComputeSinkDesc { |
| 198 | from: from_id, |
| 199 | from_desc, |
| 200 | connection: ComputeSinkConnection::Subscribe(SubscribeSinkConnection { |
| 201 | output: output.row_order().to_vec(), |
| 202 | }), |
| 203 | with_snapshot: self.with_snapshot, |
| 204 | up_to: self.up_to.map(Antichain::from_elem).unwrap_or_default(), |
| 205 | // No `FORCE NOT NULL` for subscribes |
| 206 | non_null_assertions: vec![], |
| 207 | // No `REFRESH` for subscribes |
| 208 | refresh_schedule: None, |
| 209 | }; |
| 210 | df_desc.export_sink(self.sink_id, sink_description); |
| 211 | } |
| 212 | SubscribeFrom::Query { expr, desc } => { |
| 213 | // TODO: Change the `expr` type to be `HirRelationExpr` and run |
| 214 | // HIR ⇒ MIR lowering and decorrelation here. This would allow |
| 215 | // us implement something like `EXPLAIN RAW PLAN FOR SUBSCRIBE.` |
| 216 | // |
| 217 | // let typ = expr.top_level_typ(); |
| 218 | // let expr = expr.lower(&self.config)?; |
| 219 | |
| 220 | // MIR ⇒ MIR optimization (local) |
| 221 | let mut transform_ctx = TransformCtx::local( |
| 222 | &self.config.features, |
| 223 | &self.typecheck_ctx, |
| 224 | &mut df_meta, |
| 225 | Some(&mut self.metrics), |
| 226 | Some(self.view_id), |
| 227 | ); |
| 228 | |
| 229 | let expr = expr.lower(HirToMirConfig::from(&self.config), None)?; |
| 230 | let expr = optimize_mir_local(expr, &mut transform_ctx)?; |
nothing calls this directly
no test coverage detected