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

Method create_relation_instance

prqlc/prqlc/src/sql/pq/context.rs:150–171  ·  view source on GitHub ↗

Creates a new table instance and registers it in the AnchorContext's table_instances HashMap. Also generates new IDs and names for columns as needed.

(
        &mut self,
        table_ref: TableRef,
        cid_redirects: HashMap<CId, CId>,
    )

Source from the content-addressed store, hash-verified

148 /// table_instances HashMap. Also generates new IDs and names for columns
149 /// as needed.
150 pub fn create_relation_instance(
151 &mut self,
152 table_ref: TableRef,
153 cid_redirects: HashMap<CId, CId>,
154 ) -> RIId {
155 let riid = self.riid.gen();
156
157 for (col, cid) in &table_ref.columns {
158 let def = ColumnDecl::RelationColumn(riid, *cid, col.clone());
159 self.column_decls.insert(*cid, def);
160 }
161
162 let original_cids = table_ref.columns.iter().map(|(_, c)| *c).collect();
163 let relation_instance = RelationInstance {
164 table_ref,
165 cid_redirects,
166 original_cids,
167 };
168
169 self.relation_instances.insert(riid, relation_instance);
170 riid
171 }
172
173 /// Returns the name of a column if it has been given a name already, or generates
174 /// a new name for it and registers it in the AnchorContext's column_names HashMap.

Callers 3

anchor_splitFunction · 0.80
wrapFunction · 0.80
unionFunction · 0.80

Calls 6

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

Tested by

no test coverage detected