{"record":{"id":"f37683df8463b7bb","repo":"risingwavelabs/risingwave","slug":"cannot-derive-generated-columns-or-the-rw-timest","errorCode":null,"errorMessage":"cannot derive generated columns or the `_rw_timestamp` system column in a sink catalog, but found one","messagePattern":"cannot derive generated columns or the `_rw_timestamp` system column in a sink catalog, but found one","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/handler/create_sink.rs","lineNumber":544,"sourceCode":"            .chain(\n                dependent_secrets\n                    .iter()\n                    .copied()\n                    .map(|id| id.as_object_id()),\n            )\n            .collect();\n\n    let sink_catalog = sink_desc.into_catalog(\n        sink_schema_id,\n        sink_database_id,\n        session.user_id(),\n        connector_conn_ref,\n    );\n\n    if let Some(table_catalog) = &target_table_catalog {\n        for column in sink_catalog.full_columns() {\n            if !column.can_dml() {\n                unreachable!(\n                    \"cannot derive generated columns or the `_rw_timestamp` system column in a sink catalog, but found one\"\n                );\n            }\n        }\n\n        let table_columns_without_rw_timestamp = table_catalog.columns_without_rw_timestamp();\n        let exprs = derive_default_column_project_for_sink(\n            &sink_catalog,\n            sink_plan.schema(),\n            &table_columns_without_rw_timestamp,\n            user_specified_columns,\n        )?;\n\n        let logical_project = generic::Project::new(exprs, sink_plan);\n\n        sink_plan = StreamProject::new(logical_project).into();\n\n        let exprs = LogicalSource::derive_output_exprs_from_generated_columns(","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/handler/create_sink.rs#L526-L562","documentation":"`gen_sink_plan` hits an `unreachable!` when, for a sink targeting an internal table, the derived sink catalog contains a column that cannot be DML'd — a generated column or the `_rw_timestamp` system column. Sink catalogs are supposed to contain only real, writable columns because sinks only insert derived values; presence of a generated/system column means the catalog derivation produced something unexpected.","triggerScenarios":"Creating a sink whose downstream target table (via `target_table_catalog`) has the sink catalog derivation (`derive_sink_catalog`) yield generated columns or `_rw_timestamp` — e.g. sinking into a table with generated columns where the sink-from-table path picks up those columns.","commonSituations":"`CREATE SINK s FROM t INTO target_table` where `target_table` contains generated columns or was altered to add `_rw_timestamp`; planner regressions after adding new hidden column kinds that forgot to update `can_dml` handling.","solutions":["Remove generated columns from the target table, or sink into a table without generated columns.","Filter sink columns explicitly (`CREATE SINK ... AS SELECT <only base columns>`) instead of `FROM t` style all-column sinks.","Upgrade RisingWave — later versions handle generated/system columns in sink catalogs more gracefully.","Internal fix: skip non-DML columns in sink catalog derivation rather than unreachable!."],"exampleFix":"// before\nCREATE SINK s FROM t INTO target_table; -- target_table has generated column gc\n// after\nCREATE SINK s AS SELECT id, payload FROM t; -- exclude generated columns","handlingStrategy":"validation","validationCode":"-- ensure the target table has no generated columns before sinking into it\nSELECT column_name, is_generated\nFROM information_schema.columns\nWHERE table_name = 'target_table' AND is_generated = 'ALWAYS';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sink into tables without generated columns, or use explicit column lists in the sink query.","Prefer `CREATE SINK ... AS SELECT <cols>` over `FROM t` sinks to control the schema.","Re-check target table DDL after any ALTER before creating sinks."],"tags":["sink","generated-columns","internal-error","dml"],"backgroundTag":"internal-invariant-violation","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"}