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

Function try_into_exprs

prqlc/prqlc/src/sql/gen_projection.rs:18–53  ·  view source on GitHub ↗
(
    cids: Vec<CId>,
    ctx: &mut Context,
    span: Option<Span>,
)

Source from the content-addressed store, hash-verified

16use crate::{Error, Span, WithErrorInfo};
17
18pub(super) fn try_into_exprs(
19 cids: Vec<CId>,
20 ctx: &mut Context,
21 span: Option<Span>,
22) -> Result<Vec<sql_ast::Expr>> {
23 let (cids, excluded) = translate_wildcards(&ctx.anchor, cids);
24
25 let mut res = Vec::new();
26 for cid in cids {
27 let decl = ctx.anchor.column_decls.get(&cid).unwrap();
28
29 let ColumnDecl::RelationColumn(riid, _, RelationColumn::Wildcard) = decl else {
30 // base case
31 res.push(translate_cid(cid, ctx)?.into_ast());
32 continue;
33 };
34
35 // star
36 let t = &ctx.anchor.relation_instances[riid];
37 let table_name = t.table_ref.name.clone().map(Ident::from_name);
38
39 let ident = translate_star(ctx, span)?;
40 if let Some(excluded) = excluded.get(&cid) {
41 if !excluded.is_empty() {
42 return Err(
43 Error::new_simple("Excluding columns not supported in this position")
44 .with_span(span),
45 );
46 }
47 }
48 let ident = translate_ident(table_name, Some(ident), ctx);
49
50 res.push(sql_ast::Expr::CompoundIdentifier(ident));
51 }
52 Ok(res)
53}
54
55type Excluded = HashMap<CId, HashSet<CId>>;
56

Callers 2

translate_windowedFunction · 0.85

Calls 10

translate_wildcardsFunction · 0.85
translate_cidFunction · 0.85
translate_starFunction · 0.85
translate_identFunction · 0.85
pushMethod · 0.80
into_astMethod · 0.80
mapMethod · 0.80
is_emptyMethod · 0.80
with_spanMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected