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

Function translate_exclude

prqlc/prqlc/src/sql/gen_projection.rs:197–236  ·  view source on GitHub ↗
(
    ctx: &mut Context,
    excluded: HashSet<CId>,
)

Source from the content-addressed store, hash-verified

195}
196
197fn translate_exclude(
198 ctx: &mut Context,
199 excluded: HashSet<CId>,
200) -> Option<WildcardAdditionalOptions> {
201 let excluded = as_col_names(&excluded, &ctx.anchor);
202
203 let Some(supported) = ctx.dialect.column_exclude() else {
204 // TODO: eventually this should throw an error
205 // I don't want to do this now, because we have no way around it.
206 // We could also ask the user to add table definitions.
207 if log::log_enabled!(log::Level::Warn) {
208 let excluded = excluded.join(", ");
209
210 log::warn!("Columns {excluded} will be included with *, but were not requested.")
211 }
212 return None;
213 };
214
215 let mut excluded = excluded
216 .into_iter()
217 .map(|name| translate_ident_part(name.to_string(), ctx))
218 .collect_vec();
219
220 Some(match supported {
221 ColumnExclude::Exclude => {
222 let excluded_object_names = excluded.into_iter().map(ObjectName::from).collect();
223 WildcardAdditionalOptions {
224 opt_exclude: Some(ExcludeSelectItem::Multiple(excluded_object_names)),
225 ..Default::default()
226 }
227 }
228 ColumnExclude::Except => WildcardAdditionalOptions {
229 opt_except: Some(ExceptSelectItem {
230 first_element: excluded.remove(0),
231 additional_elements: excluded,
232 }),
233 ..Default::default()
234 },
235 })
236}
237
238fn as_col_names<'a>(cids: &'a HashSet<CId>, ctx: &'a AnchorContext) -> Vec<&'a str> {
239 cids.iter()

Callers 1

translate_select_itemsFunction · 0.85

Calls 6

as_col_namesFunction · 0.85
translate_ident_partFunction · 0.85
mapMethod · 0.80
into_iterMethod · 0.80
column_excludeMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected