risingwavelabs/risingwave · error · SinkError::Config

Column `{}` in Postgres table `{}` has type `{}`, but sink s

Error message

Column `{}` in Postgres table `{}` has type `{}`, but sink schema defines it as type `{}`

What it means

After matching names, validate_pg_type_to_rw_type checks that each sink column's RisingWave type is compatible with the Postgres column's type. If the PG column's type cannot be mapped/validated against the RW type, creation fails with this message showing both types.

Source

Thrown at src/connector/src/sink/postgres.rs:293

                }

                let pg_columns_lookup = pg_columns
                    .iter()
                    .map(|c| (c.name.clone(), c.data_type.clone()))
                    .collect::<BTreeMap<_, _>>();
                for sink_column in sink_columns {
                    let pg_column = pg_columns_lookup.get(&sink_column.name);
                    match pg_column {
                        None => {
                            return Err(SinkError::Config(anyhow!(
                                "Column `{}` not found in Postgres table `{}`",
                                sink_column.name,
                                self.config.table
                            )));
                        }
                        Some(pg_column) => {
                            if !validate_pg_type_to_rw_type(pg_column, &sink_column.data_type()) {
                                return Err(SinkError::Config(anyhow!(
                                    "Column `{}` in Postgres table `{}` has type `{}`, but sink schema defines it as type `{}`",
                                    sink_column.name,
                                    self.config.table,
                                    pg_column,
                                    sink_column.data_type()
                                )));
                            }
                        }
                    }
                }
            }

            // check that pk matches
            {
                let pg_pk_names = pg_table.pk_names();
                let sink_pk_names = self
                    .pk_indices
                    .iter()

View on GitHub (pinned to 6469eb736d)

Solutions

  1. CAST the column in the sink query to a type compatible with the Postgres column: SELECT col::int FROM ....
  2. ALTER the Postgres column type (ALTER TABLE ... ALTER COLUMN ... TYPE ...) to match the sink schema.
  3. Compare the PG type printed in the error with the RW type and pick a pair validate_pg_type_to_rw_type accepts (e.g. int4<->int, int8<->bigint, text<->varchar).

Example fix

-- before
CREATE SINK s AS SELECT id::varchar AS id FROM mv WITH (connector='postgres', table='t'); -- t.id is int4
-- after
CREATE SINK s AS SELECT id::int AS id FROM mv WITH (connector='postgres', table='t');
Defensive patterns

Strategy: validation

Validate before calling

SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 't';
-- cast sink columns to matching types, e.g. col::int

Prevention

When it happens

Trigger: Sink schema declares e.g. an INTEGER for a PG column of type text/bytea/timestamp, or vice versa — any pairing validate_pg_type_to_rw_type rejects.

Common situations: PG table column altered to a different type after sink design; casting mistakes in the CREATE SINK query (e.g. sinking a varchar into an int column); using serial/bigserial columns with mismatched RW integer widths.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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