{"record":{"id":"c3906566f087ba90","repo":"risingwavelabs/risingwave","slug":"order-key-column-does-not-exist-in-schema","errorCode":null,"errorMessage":"Order key column does not exist in schema: {}","messagePattern":"Order key column does not exist in schema: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/iceberg/create_table.rs","lineNumber":578,"sourceCode":"\npub fn validate_order_key_columns<'a>(\n    order_key: &str,\n    columns: impl IntoIterator<Item = &'a str>,\n) -> std::result::Result<Vec<IcebergOrderKeyField>, anyhow::Error> {\n    let parsed = parse_order_key_exprs(order_key.to_owned())?;\n    let columns = columns\n        .into_iter()\n        .map(|column| column.to_ascii_lowercase())\n        .collect::<std::collections::HashSet<_>>();\n    for item in &parsed {\n        if item.column.starts_with('_') {\n            bail!(\n                \"System column `{}` is not allowed in order_key\",\n                item.column\n            );\n        }\n        if !columns.contains(&item.column.to_ascii_lowercase()) {\n            bail!(\"Order key column does not exist in schema: {}\", item.column);\n        }\n    }\n    Ok(parsed)\n}\n\nfn build_sort_order(order_key: &str, schema: &iceberg::spec::Schema) -> Result<SortOrder> {\n    let order_fields = validate_order_key_columns(\n        order_key,\n        schema\n            .as_struct()\n            .fields()\n            .iter()\n            .map(|field| field.name.as_str()),\n    )?;\n    let mut builder = SortOrder::builder();\n    for field in order_fields {\n        let source_id = schema.field_id_by_name(&field.column).ok_or_else(|| {\n            anyhow!(","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/iceberg/create_table.rs#L560-L596","documentation":"RisingWave validates each column named in an iceberg sink's order_key against the set of columns in the sink schema (case-insensitively). If an order-key column name is not found in the schema, table creation is aborted with this error because a sort order can only reference existing fields.","triggerScenarios":"Creating an iceberg sink with an `order_key` option containing a column name that is misspelled, differs in case beyond ASCII-lowercase matching, was renamed, or is a system column filtered out earlier in validation.","commonSituations":"Typos in DDL, copying order_key from another sink with a different schema, renaming a column in the source materialized view without updating the sink's order_key.","solutions":["Fix the order_key option to use a column that exists in the sink schema","Check exact column names with `SHOW COLUMNS FROM <mv>` before creating the sink","Remove the invalid column from order_key, keeping only valid ones"],"exampleFix":"// before\nWITH (connector='iceberg', order_key='event_tme, user_id')\n// after\nWITH (connector='iceberg', order_key='event_time, user_id')","handlingStrategy":"validation","validationCode":"let order_cols: Vec<&str> = order_key.split(',').map(str::trim).collect();\nlet schema_cols: Vec<String> = mv_columns.iter().map(|c| c.name.to_ascii_lowercase()).collect();\nfor col in &order_cols {\n    assert!(schema_cols.contains(&col.to_ascii_lowercase()), \"order_key column {col} not in schema\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy column names from SHOW COLUMNS output, not memory","Keep order_key columns in sync when altering upstream schemas","Use ASCII-lowercase comparison when matching columns"],"tags":["iceberg","sink","config-validation","sql"],"backgroundTag":"schema-validation-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}