Closed
Description
When trying to create HNSW indices for pgvector columns in Atlas HCL, the generated SQL is missing required operator class and parameters.
Given this simplified schema:
schema "public" {}
extension "vector" {
schema = schema.public
version = "0.8.0"
}
table "items" {
schema = schema.public
column "id" {
type = text
null = false
}
column "embedding" {
type = sql("vector(384)")
null = true
}
primary_key {
columns = [column.id]
}
index "hnsw_embedding_idx" {
type = "HNSW"
columns = [column.embedding]
}
}
Atlas generates:
CREATE INDEX "hnsw_embedding_idx" ON "public"."items" USING HNSW ("embedding");
Which fails with:
pq: data type vector has no default operator class for access method "hnsw"
The correct SQL should be:
CREATE INDEX "hnsw_embedding_idx" ON "public"."items"
USING hnsw ((embedding vector_l2_ops))
WITH (m=16, ef_construction=64);
Currently there's no way to specify:
- The operator class (
vector_l2_ops
,vector_ip_ops
, orvector_cosine_ops
) - The required HNSW parameters (
m
,ef_construction
)
I tried various approaches including:
index "hnsw_embedding_idx" {
type = sql("hnsw")
columns = [column.embedding]
options = sql("WITH (m=16, ef_construction=64)")
}
But none worked properly with Atlas's HCL syntax.
This is related to #3222.
Metadata
Metadata
Assignees
Labels
No labels