risingwavelabs/risingwave · error

Order key column does not exist in schema

Error message

Order key column does not exist in schema: {}

What it means

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.

Solutions

  1. Fix the order_key option to use a column that exists in the sink schema
  2. Check exact column names with `SHOW COLUMNS FROM <mv>` before creating the sink
  3. Remove the invalid column from order_key, keeping only valid ones

Example fix

// before
WITH (connector='iceberg', order_key='event_tme, user_id')
// after
WITH (connector='iceberg', order_key='event_time, user_id')
Defensive patterns

Strategy: validation

Validate before calling

let order_cols: Vec<&str> = order_key.split(',').map(str::trim).collect();
let schema_cols: Vec<String> = mv_columns.iter().map(|c| c.name.to_ascii_lowercase()).collect();
for col in &order_cols {
    assert!(schema_cols.contains(&col.to_ascii_lowercase()), "order_key column {col} not in schema");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/c3906566f087ba90. Report an issue: GitHub.

Appendix: source

Thrown at src/connector/src/sink/iceberg/create_table.rs:578

pub fn validate_order_key_columns<'a>(
    order_key: &str,
    columns: impl IntoIterator<Item = &'a str>,
) -> std::result::Result<Vec<IcebergOrderKeyField>, anyhow::Error> {
    let parsed = parse_order_key_exprs(order_key.to_owned())?;
    let columns = columns
        .into_iter()
        .map(|column| column.to_ascii_lowercase())
        .collect::<std::collections::HashSet<_>>();
    for item in &parsed {
        if item.column.starts_with('_') {
            bail!(
                "System column `{}` is not allowed in order_key",
                item.column
            );
        }
        if !columns.contains(&item.column.to_ascii_lowercase()) {
            bail!("Order key column does not exist in schema: {}", item.column);
        }
    }
    Ok(parsed)
}

fn build_sort_order(order_key: &str, schema: &iceberg::spec::Schema) -> Result<SortOrder> {
    let order_fields = validate_order_key_columns(
        order_key,
        schema
            .as_struct()
            .fields()
            .iter()
            .map(|field| field.name.as_str()),
    )?;
    let mut builder = SortOrder::builder();
    for field in order_fields {
        let source_id = schema.field_id_by_name(&field.column).ok_or_else(|| {
            anyhow!(

View on GitHub (pinned to 6469eb736d)