{"record":{"id":"3c89a12fb260feb4","repo":"PRQL/prql","slug":"take-expected-early-or-late-found-ident","errorCode":null,"errorMessage":"`take`: expected early or late, found {ident}","messagePattern":"`take`: expected early or late, found (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/semantic/resolver/transforms.rs","lineNumber":442,"sourceCode":"                return Ok(Expr::new(ExprKind::Tuple(res)));\n            }\n\n            \"tuple_uniq\" => {\n                let [take, list] = unpack::<2>(func.args);\n\n                let take_late = {\n                    let span = take.span;\n                    let ident = take.clone().try_cast(\n                        ExprKind::into_literal,\n                        Some(\"`take`\"),\n                        \"early or late\",\n                    )?;\n\n                    match ident.to_string().as_str() {\n                        \"\\\"early\\\"\" => false,\n                        \"\\\"late\\\"\" => true,\n                        _ => {\n                            return Err(Error::new(Reason::Expected {\n                                who: Some(\"`take`\".to_string()),\n                                expected: \"early or late\".to_string(),\n                                found: ident.to_string(),\n                            })\n                            .with_span(span))\n                        }\n                    }\n                };\n\n                let list_items = list.kind.into_tuple().unwrap();\n\n                log::trace!(\"tuple_uniq before: {list_items:#?}\");\n\n                let mut list_names: Vec<String> = Vec::new();\n                let mut list_out: HashMap<String, Expr> = HashMap::new();\n\n                for item in list_items {\n                    let Some(name) = (match (&item.alias, &item.kind) {","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/semantic/resolver/transforms.rs#L424-L460","documentation":"The `take`-related dedup argument accepts only the literal values `early` or `late`, which control whether uniqueness is enforced before or after the take. Any other value passed where `early`/`late` is expected is rejected with this error at resolve time.","triggerScenarios":"Calling `std.tuple_uniq` (the `take` argument) with anything other than the string literals `\"early\"` or `\"late\"` — e.g. a misspelled value, a non-literal expression, a variable, or quoting mistakes like `'EarLY'`.","commonSituations":"Typo in the flag (`earyl`, `last`), passing a dynamic/computed value instead of a literal, or copy-pasting SQL `DISTINCT`-style options into PRQL.","solutions":["Use exactly `\"early\"` or `\"late\"` as the take argument literal.","Check spelling and case; the comparison is against `\"early\"`/`\"late\"` strings.","Remove the argument if you intended default behavior rather than a custom value."],"exampleFix":"// before\nuniq take: earyl\n// after\nuniq take: \"early\"","handlingStrategy":"validation","validationCode":"const TAKE_MODES = ['\"early\"', '\"late\"'];\nif (!TAKE_MODES.includes(mode)) throw new Error(`take mode must be \"early\" or \"late\", got ${mode}`);","typeGuard":"const isTakeMode = (v) => v === '\"early\"' || v === '\"late\"';","tryCatchPattern":"try { compile(prql) } catch (e) { if (e.message.includes('`take`: expected early or late')) { /* fix literal */ } }","preventionTips":["Keep mode values in a constant enum limited to early/late","Quote the literal in PRQL: `take: \"early\"`","Watch for case and spelling; the check is exact-match on lowercase literals"],"tags":["prql","compile-time","invalid-enum-value"],"backgroundTag":"invalid-enum-value","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"}