{"record":{"id":"1f563d2159b9378b","repo":"PRQL/prql","slug":"std-from-text-expected-a-string-literal-found","errorCode":null,"errorMessage":"std.from_text: expected a string literal, found `{found}`","messagePattern":"std\\.from_text: expected a string literal, found `(.+?)`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/semantic/resolver/transforms.rs","lineNumber":517,"sourceCode":"                // yes, this is not a transform, but this is the most appropriate place for it\n\n                let [list] = unpack::<1>(func.args);\n                let list = list.kind.into_tuple().unwrap();\n                let [a, b]: [Expr; 2] = list.try_into().unwrap();\n\n                let res = maybe_binop(Some(a), &[\"std\", \"eq\"], Some(b)).unwrap();\n                return Ok(res);\n            }\n\n            \"from_text\" => {\n                // yes, this is not a transform, but this is the most appropriate place for it\n\n                let [format, text_expr] = unpack::<2>(func.args);\n\n                let text = match text_expr.kind {\n                    ExprKind::Literal(Literal::String(text)) => text,\n                    _ => {\n                        return Err(Error::new(Reason::Expected {\n                            who: Some(\"std.from_text\".to_string()),\n                            expected: \"a string literal\".to_string(),\n                            found: format!(\"`{}`\", write_pl(text_expr.clone())),\n                        })\n                        .with_span(text_expr.span));\n                    }\n                };\n\n                let res = {\n                    let span = format.span;\n                    let format = format\n                        .try_cast(ExprKind::into_literal, Some(\"`format`\"), \"csv or json\")?\n                        .to_string();\n                    match format.as_str() {\n                        \"\\\"csv\\\"\" => from_text::parse_csv(&text)\n                            .map_err(|r| Error::new_simple(r).with_span(span))?,\n                        \"\\\"json\\\"\" => from_text::parse_json(&text)\n                            .map_err(|r| Error::new_simple(r).with_span(span))?,","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/semantic/resolver/transforms.rs#L499-L535","documentation":"`std.from_text` parses inline text (CSV/JSON) into a table at compile time, so its text argument must be a literal string known during compilation. If the second argument is not a `Literal::String` (e.g. a variable, column reference, or computed expression), the resolver cannot parse it and throws this error.","triggerScenarios":"Calling `from_text format:\"csv\" ...` where the text argument is an expression instead of a quoted literal — e.g. `from_text format:\"csv\" text:my_column`, concatenation, or a value read from another pipeline stage.","commonSituations":"Trying to load data from a column or a runtime-computed string, interpolating a variable into `from_text`, or forgetting quotes around the CSV/JSON text.","solutions":["Pass the text as a quoted literal string: `from_text format:\"csv\" text:\"a,b\\n1,2\"`.","If the data is in a table/column already, don't use `from_text` — query it directly.","If the string must be dynamic, compute it outside PRQL or embed it as a literal in generated PRQL."],"exampleFix":"// before\nfrom_text format:\"csv\" text: csv_data\n// after\nfrom_text format:\"csv\" text:\"id,name\\n1,alice\"","handlingStrategy":"validation","validationCode":"if (typeof text !== 'string') throw new Error('from_text requires a string literal, got: ' + typeof text);","typeGuard":"const isStringLiteral = (v) => typeof v === 'string';","tryCatchPattern":"try { compile(prql) } catch (e) { if (e.message.includes('from_text: expected a string literal')) { /* inline the data as a quoted literal */ } }","preventionTips":["Always inline the CSV/JSON payload as a quoted PRQL string literal","Never pass columns or pipeline values to from_text — it parses at compile time","Escape newlines/quotes correctly when embedding data in the literal"],"tags":["prql","compile-time","literal-required","from-text"],"backgroundTag":"invalid-argument-format","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"}