{"record":{"id":"0f6f7245a47078b2","repo":"risingwavelabs/risingwave","slug":"column-not-found-in-postgres-table","errorCode":null,"errorMessage":"Column `{}` not found in Postgres table `{}`","messagePattern":"Column `(.+?)` not found in Postgres table `(.+?)`","errorType":"validation","errorClass":"SinkError::Config","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/postgres.rs","lineNumber":285,"sourceCode":"                let pg_columns = pg_table.column_descs();\n                let sink_columns = self.schema.fields();\n                if pg_columns.len() < sink_columns.len() {\n                    return Err(SinkError::Config(anyhow!(\n                        \"Column count mismatch: Postgres table has {} columns, but sink schema has {} columns, sink should have less or equal columns to the Postgres table\",\n                        pg_columns.len(),\n                        sink_columns.len()\n                    )));\n                }\n\n                let pg_columns_lookup = pg_columns\n                    .iter()\n                    .map(|c| (c.name.clone(), c.data_type.clone()))\n                    .collect::<BTreeMap<_, _>>();\n                for sink_column in sink_columns {\n                    let pg_column = pg_columns_lookup.get(&sink_column.name);\n                    match pg_column {\n                        None => {\n                            return Err(SinkError::Config(anyhow!(\n                                \"Column `{}` not found in Postgres table `{}`\",\n                                sink_column.name,\n                                self.config.table\n                            )));\n                        }\n                        Some(pg_column) => {\n                            if !validate_pg_type_to_rw_type(pg_column, &sink_column.data_type()) {\n                                return Err(SinkError::Config(anyhow!(\n                                    \"Column `{}` in Postgres table `{}` has type `{}`, but sink schema defines it as type `{}`\",\n                                    sink_column.name,\n                                    self.config.table,\n                                    pg_column,\n                                    sink_column.data_type()\n                                )));\n                            }\n                        }\n                    }\n                }","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/postgres.rs#L267-L303","documentation":"Each column name in the sink schema must exist in the destination Postgres table. Validation builds a BTreeMap lookup of PG column names and fails as soon as a sink column name is absent, since there would be no target column to write into.","triggerScenarios":"CREATE SINK selects or renames a column (e.g. via AS alias) that does not exist in the Postgres table specified by `table`.","commonSituations":"Case-sensitivity mismatches (unquoted PG identifiers are lowercased); renamed column in RW query; PG table schema drifted from what the sink was designed against.","solutions":["Rename the column in the sink query (AS <pg_column_name>) to match an existing Postgres column.","Add the missing column to the Postgres table with the exact name (quote it if it contains uppercase).","Check identifier case: Postgres folds unquoted names to lowercase; use quoted identifiers consistently on both sides."],"exampleFix":"-- before\nCREATE SINK s AS SELECT user_id AS uid FROM mv WITH (connector='postgres', table='t');\n-- after\nCREATE SINK s AS SELECT user_id AS user_id FROM mv WITH (connector='postgres', table='t');","handlingStrategy":"validation","validationCode":"SELECT column_name FROM information_schema.columns WHERE table_name = 't';\n-- every sink output column name must appear here","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use AS aliases in the sink query to exactly match PG column names.","Remember unquoted PG identifiers are lowercased."],"tags":["rust","postgres","sink","schema"],"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"}