Rewrite every global `Get` in `expr` from the catalog's assigned id back to the script's id, looked up by the object's name.
(
expr: &mut MirRelationExpr,
catalog: &TestCatalog,
name_to_id: &BTreeMap<String, GlobalId>,
)
| 308 | /// Rewrite every global `Get` in `expr` from the catalog's assigned id back to |
| 309 | /// the script's id, looked up by the object's name. |
| 310 | fn remap_gets( |
| 311 | expr: &mut MirRelationExpr, |
| 312 | catalog: &TestCatalog, |
| 313 | name_to_id: &BTreeMap<String, GlobalId>, |
| 314 | ) -> anyhow::Result<()> { |
| 315 | expr.try_visit_mut_post::<_, anyhow::Error>(&mut |e| { |
| 316 | if let MirRelationExpr::Get { |
| 317 | id: Id::Global(g), .. |
| 318 | } = e |
| 319 | { |
| 320 | let name = catalog |
| 321 | .get_source_name(g) |
| 322 | .ok_or_else(|| anyhow::anyhow!("get of unknown catalog object {g}"))?; |
| 323 | let id = name_to_id |
| 324 | .get(name) |
| 325 | .ok_or_else(|| anyhow::anyhow!("get of unregistered object {name}"))?; |
| 326 | *g = *id; |
| 327 | } |
| 328 | Ok(()) |
| 329 | }) |
| 330 | } |
| 331 | |
| 332 | /// A command read from the script stream. |
| 333 | /// |
no test coverage detected