risingwavelabs/risingwave · error · SinkError::LanceDb

column order mismatch at position {}: LanceDB column is '{}'

Error message

column order mismatch at position {}: LanceDB column is '{}', RisingWave column is '{}'

What it means

After confirming equal field counts, validate_ordered_schema compares columns position-by-position and requires identical names in identical order. Any position where the LanceDB column name differs from the RisingWave column name fails validation, including pure reorderings (same set of names, wrong order).

Source

Thrown at src/connector/src/sink/lancedb.rs:306

    rw_arrow_schema: &arrow_schema::Schema,
    lance_schema: &arrow_schema::Schema,
) -> Result<()> {
    if rw_arrow_schema.fields().len() != lance_schema.fields().len() {
        return Err(SinkError::LanceDb(anyhow!(
            "Columns mismatch. RisingWave schema has {} fields, LanceDB table has {} fields",
            rw_arrow_schema.fields().len(),
            lance_schema.fields().len()
        )));
    }

    for (idx, (rw_field, lance_field)) in rw_arrow_schema
        .fields()
        .iter()
        .zip_eq_fast(lance_schema.fields().iter())
        .enumerate()
    {
        if rw_field.name() != lance_field.name() {
            return Err(SinkError::LanceDb(anyhow!(
                "column order mismatch at position {}: LanceDB column is '{}', RisingWave column is '{}'",
                idx,
                lance_field.name(),
                rw_field.name()
            )));
        }

        if rw_field.data_type() != lance_field.data_type() {
            return Err(SinkError::LanceDb(anyhow!(
                "column '{}' type mismatch: LanceDB type is {:?}, RisingWave type is {:?}",
                rw_field.name(),
                lance_field.data_type(),
                rw_field.data_type()
            )));
        }
    }

    Ok(())

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Reorder the sink query's SELECT list to match the LanceDB table's column order exactly
  2. Recreate the LanceDB table with columns in the RisingWave order
  3. Point the sink at a new table so RW creates it with its own ordering

Example fix

// before
CREATE SINK s AS SELECT b, a FROM t WITH (...); -- table is (a, b)
// after
CREATE SINK s AS SELECT a, b FROM t WITH (...);
Defensive patterns

Strategy: validation

Validate before calling

async function checkColumnOrder(tableName, rwColumns) {
  const schema = await (await conn.openTable(tableName)).schema();
  schema.fields.forEach((f, i) => {
    if (f.name !== rwColumns[i]) throw new Error(`position ${i}: table=${f.name} sink=${rwColumns[i]}`);
  });
}

Try / catch

catch (SinkError::LanceDb(e)) if e.includes("column order mismatch") { reorder the sink SELECT list to match the table }

Prevention

When it happens

Trigger: Sink query column order differs from the existing LanceDB table's column order, e.g., RW expects (a, b) but the table stores (b, a).

Common situations: Rewriting the sink query with columns in a different order; schema evolution where a column was inserted in the middle on one side; reusing a table created by another tool.

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/06780ff1f5af1e81. Report an issue: GitHub.