{"record":{"id":"cdf35468ba264e31","repo":"PRQL/prql","slug":"error","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"prqlc/prqlc-macros/src/lib.rs","lineNumber":32,"sourceCode":"\n#[proc_macro]\npub fn prql_to_sql(input: TokenStream) -> TokenStream {\n    let input: Expr = syn::parse(input).unwrap();\n\n    let prql_string = match input {\n        Expr::Lit(ExprLit {\n            lit: Lit::Str(lit_str),\n            ..\n        }) => lit_str.value(),\n        _ => panic!(\"prql_to_sql! proc macro expected a string\"),\n    };\n\n    let opts = prqlc::Options::default().no_format().no_signature();\n\n    let sql_string = match prqlc::compile(&prql_string, &opts) {\n        Ok(r) => r,\n        Err(err) => {\n            panic!(\"{}\", err);\n        }\n    };\n\n    TokenStream::from_iter(vec![TokenTree::Literal(Literal::string(&sql_string))])\n}\n","sourceCodeStart":14,"sourceCodeEnd":38,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc-macros/src/lib.rs#L14-L38","documentation":"prql_to_sql! delegates to prqlc::compile; if the PRQL source fails to compile (parse or semantic error), the macro panics with the compiler error message. Since the macro runs at compile time, a bad PRQL string becomes a compile error of the Rust crate containing the macro invocation, with the PRQL error text in the panic message.","triggerScenarios":"Any syntactically or semantically invalid PRQL passed to prql_to_sql! — typos in transforms, unknown functions, bad types, referencing missing columns, or a version mismatch between macro and intended syntax.","commonSituations":"Editing an embedded query and introducing a PRQL syntax error; using a PRQL feature unsupported by the pinned prqlc version; copy-pasting SQL that is not valid PRQL.","solutions":["Read the PRQL error in the panic message and fix the query syntax/semantics","Test the query first with `cargo run -p prqlc -- compile query.prql` or the PRQL playground to get better diagnostics","Verify the prqlc version pinned in Cargo.toml supports the syntax used","Temporarily compile at runtime with prqlc::compile to get a Result instead of a panic"],"exampleFix":"// before\nlet sql = prql_to_sql!(\"from emplyees | take 5\");\n// after\nlet sql = prql_to_sql!(\"from employees | take 5\");","handlingStrategy":"validation","validationCode":"// Validate PRQL before committing it into the macro\n// $ cargo run -q -p prqlc -- compile query.prql","typeGuard":null,"tryCatchPattern":"// No catch possible: compile-time panic. Use runtime API to recover:\nmatch prqlc::compile(&prql_string, &opts) {\n    Ok(sql) => sql,\n    Err(e) => { log::error!(\"PRQL error: {e}\"); fallback_sql }\n}","preventionTips":["Test each PRQL query in the playground or via `prqlc compile` before embedding","Keep the prqlc version in Cargo.toml up to date and re-check queries after upgrades","Add a unit test compiling every embedded query string"],"tags":["rust","proc-macro","prql","compile-error"],"backgroundTag":"sql-query-failed","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}