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

Function remap_gets

src/clusterd-test-driver/src/script.rs:310–330  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

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.
310fn 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///

Callers 1

executeMethod · 0.85

Calls 2

get_source_nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected