risingwavelabs/risingwave · error

unexpected statement type: {:?}

Error message

unexpected statement type: {:?}

What it means

`generate_stream_graph_for_replace_table` destructures a `CreateStatement` with a let-else; any other statement type reaches a `panic!`. This is an internal invariant violation: callers should only pass CREATE TABLE/SOURCE statements suitable for table replacement.

Source

Thrown at src/frontend/src/handler/create_table.rs:2300

    TableJobType,
)> {
    let Statement::CreateTable {
        columns,
        constraints,
        source_watermarks,
        append_only,
        on_conflict,
        with_version_columns,
        wildcard_idx,
        cdc_table_info,
        format_encode,
        include_column_options,
        engine,
        with_options,
        ..
    } = statement
    else {
        panic!("unexpected statement type: {:?}", statement);
    };

    let format_encode = format_encode
        .clone()
        .map(|format_encode| format_encode.into_v2_with_warning());

    let engine = match engine {
        risingwave_sqlparser::ast::Engine::Hummock => Engine::Hummock,
        risingwave_sqlparser::ast::Engine::Iceberg => Engine::Iceberg,
    };

    let is_drop_connector =
        original_catalog.associated_source_id().is_some() && format_encode.is_none();
    if is_drop_connector {
        debug_assert!(
            source_watermarks.is_empty()
                && include_column_options.is_empty()
                && with_options

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Verify the SQL statement being replaced is a CREATE TABLE statement created with connector semantics
  2. If reproducible with normal SQL, file a RisingWave bug with the statement and version
  3. Check RisingWave version for known fixes to replace-table planning
Defensive patterns

Strategy: try-catch

Try / catch

match replace_table_plan(stmt) {
    Err(e) if e.to_string().contains("unexpected statement type") => {
        // internal bug path: log statement, report to RisingWave
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling the replace-table planning path with a statement that is not a `CreateStatement` — e.g. an internal bug passing `CreateSource` variants lacking those fields or a completely different statement kind through `get_replace_table_plan`.

Common situations: Hitting this during `ALTER TABLE ... ADD COLUMN` / replace workflows after an upgrade; a RisingWave bug rather than user error.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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