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

Function prql_to_sql

prqlc/prqlc-macros/src/lib.rs:16–37  ·  view source on GitHub ↗
(input: TokenStream)

Source from the content-addressed store, hash-verified

14
15#[proc_macro]
16pub fn prql_to_sql(input: TokenStream) -> TokenStream {
17 let input: Expr = syn::parse(input).unwrap();
18
19 let prql_string = match input {
20 Expr::Lit(ExprLit {
21 lit: Lit::Str(lit_str),
22 ..
23 }) => lit_str.value(),
24 _ => panic!("prql_to_sql! proc macro expected a string"),
25 };
26
27 let opts = prqlc::Options::default().no_format().no_signature();
28
29 let sql_string = match prqlc::compile(&prql_string, &opts) {
30 Ok(r) => r,
31 Err(err) => {
32 panic!("{}", err);
33 }
34 };
35
36 TokenStream::from_iter(vec![TokenTree::Literal(Literal::string(&sql_string))])
37}

Callers

nothing calls this directly

Calls 5

no_signatureMethod · 0.80
no_formatMethod · 0.80
parseFunction · 0.50
compileFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected