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

Method ensure_column_name

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

Returns the name of a column if it has been given a name already, or generates a new name for it and registers it in the AnchorContext's column_names HashMap.

(&mut self, cid: CId)

Source from the content-addressed store, hash-verified

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.
175 pub(crate) fn ensure_column_name(&mut self, cid: CId) -> Option<&String> {
176 // don't name wildcards & named RelationColumns
177 let decl = &self.column_decls[&cid];
178 if let ColumnDecl::RelationColumn(_, _, col) = decl {
179 match col {
180 RelationColumn::Single(Some(name)) => {
181 let entry = self.column_names.entry(cid);
182 return Some(entry.or_insert_with(|| name.clone()));
183 }
184 RelationColumn::Wildcard => return None,
185 _ => {}
186 }
187 }
188
189 let entry = self.column_names.entry(cid);
190 Some(entry.or_insert_with(|| self.col_name.gen()))
191 }
192
193 pub(super) fn load_names(
194 &mut self,

Callers 3

anchor_splitFunction · 0.80
ensure_namesFunction · 0.80
fold_sql_queryMethod · 0.80

Calls 1

genMethod · 0.80

Tested by

no test coverage detected