risingwavelabs/risingwave · error · anyhow::Error

PostgreSQL schema `{schema}` does not exist

Error message

PostgreSQL schema `{schema}` does not exist

What it means

ensure_table_privilege validates that the configured PostgreSQL user can read the source table. This error is returned when the catalog query reports the schema itself does not exist on the upstream PostgreSQL server, so privilege checks cannot proceed.

Source

Thrown at src/connector/src/connector_common/postgres.rs:339

        let row = sqlx::query(CHECK_TABLE_PRIVILEGE_QUERY)
            .bind(schema)
            .bind(table)
            .bind(required_privilege)
            .fetch_one(connection)
            .await
            .context("Failed to check PostgreSQL table privileges")?;

        let privilege_status = PostgresTablePrivilege {
            user_name: row.get("user_name"),
            schema_exists: row.get("schema_exists"),
            table_exists: row.get("table_exists"),
            has_schema_usage: row.get("has_schema_usage"),
            has_table_privilege: row.get("has_table_privilege"),
            has_any_column_privilege: row.get("has_any_column_privilege"),
        };

        if !privilege_status.schema_exists {
            return Err(anyhow!("PostgreSQL schema `{schema}` does not exist").into());
        }

        if !privilege_status.table_exists {
            return Err(anyhow!("PostgreSQL table `{schema}`.`{table}` does not exist").into());
        }

        if !privilege_status.has_schema_usage {
            return Err(anyhow!(
                "PostgreSQL table {} exists, but the connection user `{}` does not have USAGE privilege on schema `{}`. Grant privileges on the upstream PostgreSQL database: {}",
                format_pg_table_name(schema, table),
                privilege_status.user_name,
                schema,
                format_grant_usage(schema, &privilege_status.user_name),
            )
            .into());
        }

        if !privilege_status.has_table_privilege {

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Verify the schema exists: `SELECT 1 FROM information_schema.schemata WHERE schema_name = '<schema>';` on the configured database.
  2. Check the connection string/`database.name` option points at the intended database.
  3. Correct the schema name in the source configuration, honoring case sensitivity (quote if created quoted).
  4. Ensure the connection user has permission to see the schema (USAGE/grant visibility).

Example fix

// before
CREATE TABLE t (...) WITH (connector = 'postgres-cdc', schema.name = 'Public', table.name = 'users')
// after: match actual schema case
schema.name = 'public'
Defensive patterns

Strategy: validation

Validate before calling

// check upstream schema before creating the source
SELECT 1 FROM information_schema.schemata WHERE schema_name = 'public';

Try / catch

// surface a clear config error when the schema is absent
if err.to_string().contains("does not exist") && err.to_string().contains("schema") {
    return Err(anyhow!("fix schema.name in the source config; schema not found in the configured database"));
}

Prevention

When it happens

Trigger: Creating a CDC/table source where the `schema.name` setting names a schema absent from the configured database: typo in schema name, wrong database in connection string, case-sensitive quoted schema names, schema dropped before source creation.

Common situations: Connecting to the wrong database (schema exists in `prod` but connection points at `staging`); schema names with uppercase letters needing quoting; multi-tenant setups where search_path differs; schema renamed or dropped by migrations.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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