MCPcopy Create free account
hub / github.com/PRQL/prql / create_a_table_instance

Method create_a_table_instance

prqlc/prqlc/src/semantic/lowering.rs:471–502  ·  view source on GitHub ↗
(
        &mut self,
        id: usize,
        name: Option<String>,
        tid: TId,
    )

Source from the content-addressed store, hash-verified

469 }
470
471 fn create_a_table_instance(
472 &mut self,
473 id: usize,
474 name: Option<String>,
475 tid: TId,
476 ) -> rq::TableRef {
477 // create instance columns from table columns
478 let table = self.table_buffer.iter().find(|t| t.id == tid).unwrap();
479
480 let columns = (table.relation.columns.iter())
481 .cloned()
482 .unique()
483 .map(|col| (col, self.cid.gen()))
484 .collect_vec();
485
486 log::debug!("... columns = {columns:?}");
487
488 let input_cids: HashMap<_, _> = columns
489 .iter()
490 .cloned()
491 .enumerate()
492 .map(|(index, (col, cid))| (col, (cid, index)))
493 .collect();
494 self.node_mapping
495 .insert(id, LoweredTarget::Input(input_cids));
496 rq::TableRef {
497 source: tid,
498 name,
499 columns,
500 prefer_cte: true,
501 }
502 }
503
504 fn lower_relation(&mut self, expr: pl::Expr) -> Result<rq::Relation> {
505 let span = expr.span;

Callers 1

lower_table_refMethod · 0.80

Calls 5

iterMethod · 0.80
mapMethod · 0.80
genMethod · 0.80
collectMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected