risingwavelabs/risingwave · error

pgvector type `vector` is missing dimension, expected `vecto

Error message

pgvector type `vector` is missing dimension, expected `vector(n)`

What it means

pgvector's `vector` type requires an explicit dimension in RisingWave. `parse_pgvector_dimension` bails when the normalized type name is exactly `vector` with no `(n)` suffix, because a dimension is mandatory for the RW Vector type.

Source

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

            if let Some(dim) = parse_pgvector_dimension(name)? {
                DataType::Vector(dim)
            } else if matches!(name.to_ascii_lowercase().as_str(), "geometry" | "geography") {
                DataType::Bytea
            } else {
                // NOTES: user-defined enum type is classified as `Unknown`
                tracing::warn!("unknown PostgreSQL data type `{name}`; mapping it to varchar");
                DataType::Varchar
            }
        }
    };

    Ok(dtype)
}

fn parse_pgvector_dimension(type_name: &str) -> ConnectorResult<Option<usize>> {
    let normalized = type_name.trim().to_ascii_lowercase();
    if normalized == "vector" {
        bail!("pgvector type `vector` is missing dimension, expected `vector(n)`")
    }
    if !normalized.starts_with("vector(") || !normalized.ends_with(')') {
        return Ok(None);
    }

    let dim_text = normalized
        .trim_start_matches("vector(")
        .trim_end_matches(')')
        .trim();
    let dim = dim_text
        .parse::<usize>()
        .map_err(|_| anyhow!("invalid pgvector dimension in type `{type_name}`"))?;

    if !(1..=DataType::VEC_MAX_SIZE).contains(&dim) {
        bail!(
            "pgvector dimension out of range in type `{}`: expect 1..={}",
            type_name,
            DataType::VEC_MAX_SIZE

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Recreate/alter the upstream column with a dimension: `ALTER TABLE t ALTER COLUMN v TYPE vector(1536);`
  2. Re-run schema discovery in RisingWave after fixing the column type

Example fix

-- before
CREATE TABLE embeddings (v vector);
-- after
CREATE TABLE embeddings (v vector(1536));
Defensive patterns

Strategy: validation

Validate before calling

-- ensure the pgvector column declares a dimension
SELECT attname, atttypmod FROM pg_attribute
WHERE attrelid = 'public.embeddings'::regclass AND attname = 'v';
-- a usable atttypmod implies vector(n); 0 means bare `vector`

Type guard

fn has_vector_dimension(type_name: &str) -> bool {
    let n = type_name.trim().to_ascii_lowercase();
    n.starts_with("vector(") && n.ends_with(')')
}

Try / catch

match discovery_result {
    Err(e) if e.to_string().contains("missing dimension, expected `vector(n)`") => {
        Err(CdcError::PgVectorUndimensioned("ALTER TABLE ... ALTER COLUMN v TYPE vector(n)".into()))
    }
    other => other,
}

Prevention

When it happens

Trigger: Schema discovery on a Postgres column created as `vector` (no dimension) whose type name string reaches `parse_pgvector_dimension` via `sea_type_to_rw_type`.

Common situations: Upstream table created with untyped pgvector column (`CREATE TABLE t (v vector);`), which Postgres allows; pgvector extension used loosely without typed columns.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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