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

Function deduplicate_select_items

prqlc/prqlc/src/sql/gen_projection.rs:123–134  ·  view source on GitHub ↗
(items: &mut Vec<SelectItem>)

Source from the content-addressed store, hash-verified

121}
122
123fn deduplicate_select_items(items: &mut Vec<SelectItem>) {
124 // Dropping all duplicated identifiers
125 let mut seen = HashSet::new();
126 items.retain(|select_item| match select_item {
127 SelectItem::UnnamedExpr(sql_ast::Expr::CompoundIdentifier(idents)) => {
128 // If any of the identifiers hadn't been seen yet, retain the expr
129 idents.iter().any(|ident| seen.insert(ident.clone()))
130 }
131 SelectItem::ExprWithAlias { alias, .. } => seen.insert(alias.clone()),
132 _ => true,
133 });
134}
135
136pub(super) fn translate_select_items(
137 cols: Vec<CId>,

Callers 1

translate_select_itemsFunction · 0.85

Calls 2

iterMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected