{"record":{"id":"16367b0d9db9ede0","repo":"risingwavelabs/risingwave","slug":"invalid-order-key-item-item-hint-supported-fo","errorCode":null,"errorMessage":"Invalid order key item `{item}`\nHINT: Supported format is `column [asc|desc] [nulls first|last]`","messagePattern":"Invalid order key item `(.+?)`\nHINT: Supported format is `column \\[asc\\|desc\\] \\[nulls first\\|last\\]`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/iceberg/create_table.rs","lineNumber":495,"sourceCode":"\npub fn parse_order_key_exprs(\n    expr: String,\n) -> std::result::Result<Vec<IcebergOrderKeyField>, anyhow::Error> {\n    let mut order_keys = Vec::new();\n    let mut seen_columns = std::collections::HashSet::new();\n\n    for raw_item in expr.split(',') {\n        let item = raw_item.trim();\n        if item.is_empty() {\n            bail!(\"Invalid order key: empty item in `{expr}`\");\n        }\n\n        let tokens = item.split_whitespace().collect_vec();\n        if tokens.is_empty() {\n            bail!(\"Invalid order key item `{item}`\");\n        }\n        if tokens.len() > 4 {\n            bail!(\n                \"Invalid order key item `{item}`\\nHINT: Supported format is `column [asc|desc] [nulls first|last]`\"\n            );\n        }\n\n        let column = tokens[0];\n        if !ORDER_KEY_COLUMN_RE.is_match(column) {\n            bail!(\n                \"Invalid order key column `{column}`\\nHINT: Only plain column names are supported in order_key\"\n            );\n        }\n        if !seen_columns.insert(column.to_ascii_lowercase()) {\n            bail!(\"Duplicate column `{column}` in order_key\");\n        }\n\n        let mut direction = SortDirection::Ascending;\n        let mut null_order = None;\n        let mut idx = 1;\n        while idx < tokens.len() {","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/iceberg/create_table.rs#L477-L513","documentation":"Each order key item may contain at most 4 whitespace-separated tokens: `column [asc|desc] [nulls first|last]`. A longer token list means the item mixes in unsupported extra words (functions, expressions, multiple columns in one item). The HINT in the message documents the accepted grammar.","triggerScenarios":"order_key items like `date_trunc('day', ts)`, `a b c d e`, `id asc nulls first extra`, or comma-separated columns mistakenly written as space-separated (`id name`) instead of `id,name`.","commonSituations":"Trying to use expressions/functions in order_key (only plain column names are supported); forgetting the comma between two columns so they parse as one item; pasting a full ORDER BY clause from SQL.","solutions":["Use only plain column names, one item per column separated by commas","Convert expressions to separate computed columns in the table and reference those columns","Add the missing comma between column names (e.g. `id,name` not `id name`)","Keep optional keywords to at most two: a direction (asc/desc) and a nulls placement (nulls first/last)"],"exampleFix":"// before\norder_key = 'date_trunc(day, event_time) desc'\n// after\norder_key = 'event_day desc'  -- event_day is a materialized column","handlingStrategy":"validation","validationCode":"fn order_key_item_token_count_ok(item: &str) -> bool {\n    matches!(item.split_whitespace().count(), 1..=4)\n}","typeGuard":"fn is_simple_order_key_item(item: &str) -> bool {\n    let toks: Vec<&str> = item.split_whitespace().collect();\n    (1..=4).contains(&toks.len())\n}","tryCatchPattern":null,"preventionTips":["Remember the grammar: `column [asc|desc] [nulls first|last]` — max 4 tokens","Separate multiple columns with commas, never spaces","Do not put expressions or functions in order_key; materialize them as columns first","Never paste a raw SQL ORDER BY clause into order_key"],"tags":["validation","iceberg","sql","unsupported-syntax"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}