{"record":{"id":"6565301e66299a7c","repo":"risingwavelabs/risingwave","slug":"failed-to-refresh-schema-because-some-of-the-colum","errorCode":null,"errorMessage":"failed to refresh schema because some of the columns to drop are referenced by a generated column \"{}\"","messagePattern":"failed to refresh schema because some of the columns to drop are referenced by a generated column \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/handler/alter_table_with_sr.rs","lineNumber":86,"sourceCode":"            table_name,\n            definition,\n            &original_table,\n            SqlColumnStrategy::Ignore,\n        ))\n        .await;\n        match result {\n            Ok((source, table, graph, job_type)) => Ok((source, table, graph, job_type)),\n            Err(e) => {\n                let report = e.to_report_string();\n                // NOTE(yuhao): This is a workaround for reporting errors when columns to drop is referenced by generated column.\n                // Finding the actual columns to drop requires generating `PbSource` from the sql definition\n                // and fetching schema from schema registry, which will cause a lot of unnecessary refactor.\n                // Here we match the error message to yield when failing to bind generated column exprs.\n                let re = Regex::new(r#\"failed to bind the expression in generated column \"(.*?)\"\"#)\n                    .unwrap();\n                let captures = re.captures(&report).map_err(anyhow::Error::from)?;\n                if let Some(gen_col_name) = captures.and_then(|captures| captures.get(1)) {\n                    Err(anyhow!(e).context(format!(\"failed to refresh schema because some of the columns to drop are referenced by a generated column \\\"{}\\\"\",\n                gen_col_name.as_str())).into())\n                } else {\n                    Err(e)\n                }\n            }\n        }\n    }?;\n    let catalog_writer = session.catalog_writer()?;\n\n    catalog_writer\n        .replace_table(\n            source.map(|x| x.to_prost()),\n            table.to_prost(),\n            graph,\n            job_type,\n        )\n        .await?;\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/handler/alter_table_with_sr.rs#L68-L104","documentation":"When refreshing a schema-registry-backed table's schema, dropping columns that feed a generated column makes the generated column's expression unbindable. The code matches the inner bind error message for generated columns and re-wraps it with a clearer message naming the offending generated column; otherwise the original error propagates.","triggerScenarios":"ALTER TABLE ... REFRESH SCHEMA (schema registry update) where the new schema drops a column that a generated column expression references.","commonSituations":"Upstream producers remove fields from a protobuf/avro/json payload registered in the schema registry while the RW table has computed columns depending on those fields.","solutions":["Drop the generated column (or alter it to not reference the removed field) before refreshing the schema","Update the schema registry subject so the column remains present","Recreate the table with the new schema and regenerated computed columns"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"-- Before refresh, check generated column expressions against incoming schema fields\nSELECT name, generated_expr FROM rw_catalog.rw_columns\nWHERE relation_id = <table_id> AND generated_expr IS NOT NULL;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep generated column inputs stable in the upstream schema","Coordinate schema registry evolutions with computed column definitions","Prefer additive-only schema changes for registry-backed tables"],"tags":["frontend","schema-registry","generated-column"],"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-14T16:17:12.679Z"}