{"record":{"id":"176c58117fbc6ee2","repo":"PRQL/prql","slug":"by-expected-position-or-name-found-ident","errorCode":null,"errorMessage":"`by`: expected position or name, found {ident}","messagePattern":"`by`: expected position or name, found (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/semantic/resolver/transforms.rs","lineNumber":253,"sourceCode":"                };\n                (transform_kind, tbl)\n            }\n            \"append\" => {\n                let [by, bottom, top] = unpack::<3>(func.args);\n\n                let by_name = {\n                    let span = by.span;\n                    let ident = by.clone().try_cast(\n                        ExprKind::into_literal,\n                        Some(\"`by`\"),\n                        \"position or name\",\n                    )?;\n\n                    match ident.to_string().as_str() {\n                        \"\\\"position\\\"\" => false,\n                        \"\\\"name\\\"\" => true,\n                        _ => {\n                            return Err(Error::new(Reason::Expected {\n                                who: Some(\"`by`\".to_string()),\n                                expected: \"position or name\".to_string(),\n                                found: ident.to_string(),\n                            })\n                            .with_span(span))\n                        }\n                    }\n                };\n\n                // TODO: support database engine-level UNION ALL BY NAME in PR #6037\n                if by_name {\n                    // input validation for PRQL-native implementation\n                    for (name, rel) in [(\"top\", top.clone()), (\"bottom\", bottom.clone())] {\n                        let lineage = rel.lineage.clone().ok_or_else(|| {\n                            Error::new(Reason::Expected {\n                                who: Some(format!(\"`{name}`\")),\n                                expected: \"relation\".to_string(),\n                                found: write_pl(rel.clone()),","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/semantic/resolver/transforms.rs#L235-L271","documentation":"This error comes from PRQL's `append` transform when used with the `by` option (e.g. `append other by:...`). The `by` argument must be exactly `position` or `name`; the resolver found some other identifier instead. It is thrown because PRQL's union-all-by-name/positional implementation only supports these two explicit modes.","triggerScenarios":"Compiling a PRQL query like `from t | append other by:foo` where the identifier passed to `by:` is anything other than `position` or `name` (e.g. a misspelling like `by:name ` with an ident such as `by:Name`, `by:pos`, or a column name).","commonSituations":"Typo in `by:position`/`by:name`; passing a column name expecting `by:` to take a column; copying SQL `UNION ... BY NAME` syntax into PRQL without adapting it; confusion from older or newer PRQL syntax examples.","solutions":["Change the `by:` value to exactly `position` or `name` (lowercase).","If you intended to match on a column, use `by:name` after ensuring both inputs have identically named columns (e.g. add a `select` to align column names).","Check the PRQL version/docs: `append by:` only accepts these two keywords; positional matching is the default via plain `append other`."],"exampleFix":"// before\nfrom t | append other by:colname\n// after\nfrom t | append other by:name","handlingStrategy":"validation","validationCode":"// PRQL source check before compiling\nconst BY_KEYWORDS = new Set([\"position\", \"name\"]);\nfunction validateAppendBy(prql) {\n  const m = prql.match(/by:\\s*([\\w\"]+)/);\n  if (m && !BY_KEYWORDS.has(m[1].replaceAll('\"', ''))) {\n    throw new Error(`append by: must be 'position' or 'name', got: ${m[1]}`);\n  }\n}","typeGuard":"function isValidByKeyword(v) {\n  return v === 'position' || v === 'name';\n}","tryCatchPattern":"try {\n  const sql = prqlc.compile(query);\n} catch (e) {\n  if (e.message.includes('`by`: expected position or name')) {\n    // surface a fix hint: use by:position or by:name\n  } else throw e;\n}","preventionTips":["Always use lowercase `by:position` or `by:name` verbatim.","Do not pass column names to `by:`; align names with `select` instead.","Add a unit test per pipeline using `append by:`."],"tags":["prql","append-transform","query-compilation"],"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"}