Skip to content

pgvector typmod lost: vector/halfvec dimensions dropped in plan/apply, causing HNSW index failure ("column does not have dimensions") #295

@KrisBraun

Description

@KrisBraun

Summary

When using pgvector types with dimensions (e.g., halfvec(384) / vector(384)), pgschema appears to drop the typmod during plan/apply. The generated plan SQL creates the column as halfvec (no dimensions). This causes CREATE INDEX ... hnsw to fail with ERROR: column does not have dimensions.

Reproduction

  1. Ensure pgvector extension is available:
CREATE EXTENSION IF NOT EXISTS vector;
  1. Desired state SQL (schema.sql):
CREATE TABLE activity (
  id bigserial PRIMARY KEY,
  embedding halfvec(384)
);

CREATE INDEX activity_embedding_idx
  ON activity USING hnsw (embedding halfvec_cosine_ops);
  1. Run pgschema:
pgschema apply --file schema.sql --schema public --auto-approve \
  --host localhost --db postgres --user postgres

Optional: pgschema plan --file schema.sql --output-sql plan.sql and inspect plan.sql.

Expected

  • Column is created as halfvec(384)
  • HNSW index is created successfully

Actual

  • Plan SQL creates column as halfvec (no dimensions)
  • Apply fails with:

ERROR: column does not have dimensions (SQLSTATE 22023)

at the HNSW index creation

Environment

  • pgschema 1.7.1 (github.com/pgplex/pgschema)
  • PostgreSQL 18.x (Docker)
  • pgvector enabled
  • macOS (darwin/arm64)

Additional Notes

It looks like typmod for pgvector types is being dropped somewhere in the IR or normalization. Happy to provide full plan SQL output if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions