Skip to content

fix(pgwire): wire quantization params through CREATE/ALTER VECTOR INDEX DDL#27

Merged
farhan-syah merged 4 commits intomainfrom
fix/vector-index-ddl-quantization
Apr 14, 2026
Merged

fix(pgwire): wire quantization params through CREATE/ALTER VECTOR INDEX DDL#27
farhan-syah merged 4 commits intomainfrom
fix/vector-index-ddl-quantization

Conversation

@farhan-syah
Copy link
Copy Markdown
Contributor

Closes #25

Summary

  • CREATE VECTOR INDEX now parses INDEX_TYPE, PQ_M, IVF_CELLS, IVF_NPROBE and propagates them into VectorOp::SetParams instead of the hardcoded zeros that forced every SQL-created index to full-FP32 HNSW.
  • Unknown INDEX_TYPE values and invalid combinations (PQ_M not dividing DIM, quantization params without a PQ index type, ivf_nprobe > ivf_cells) are now rejected at the DDL layer instead of silently falling through.
  • ALTER VECTOR INDEX ... SET (...) accepts the same quantization keyword set; quantization-shape changes route through SetParams, HNSW parameter changes route through Rebuild, and a single statement may mix both.
  • execute_set_vector_params now reads the existing IndexConfig and treats zero / empty inputs as "preserve", so quantization-only ALTERs no longer clobber m / ef_construction / metric set at CREATE time.
  • pgwire/ddl/dsl.rs (594 lines, over the 500-line hard limit and on the fix's code path) split into a dsl/ directory with one handler per file so the fix could be added without pushing the file further over the limit.

Test plan

  • New integration file nodedb/tests/sql_vector_index_ddl.rs — 5 tests covering: unknown INDEX_TYPE rejection, PQ_M / DIM divisibility validation, valid hnsw_pq acceptance, valid ivf_pq acceptance, and ALTER VECTOR INDEX SET (index_type = ...) acceptance.
  • cargo nextest run -p nodedb --test sql_vector_index_ddl — 5/5 green.
  • Regression check on nearby DDL suites (sql_index_naming, sql_transactions, sql_where_expressions, sql_update_expressions) — 28/28 green.
  • cargo fmt --all clean, cargo clippy -p nodedb --tests -- -D warnings clean.

jieba-rs pulls include-flate → libflate → core2 0.4.0, which is yanked
on crates.io. The workspace [patch.crates-io] bypassed this locally but
was ignored by cargo publish's isolated packaging resolve, so releases
kept failing on nodedb-fts.

Drop jieba-rs entirely and let lang-zh fall back to CJK bigram
segmentation (the same path used when the feature is disabled). The
feature flag is retained as a no-op so downstream configs keep
compiling. Can be restored when the upstream flate chain moves off
yanked core2.
dsl.rs has grown to cover DDL parsing for search indexes, CRDT merge,
FTS, vector, sparse, and fusion in a single flat file. Split it into a
dsl/ directory with one module per concern:

  crdt_merge, fulltext_index, search_fusion, search_index,
  search_vector, sparse_index, vector_index, helpers, mod

No logic changes — pure file reorganisation.
ALTER VECTOR INDEX SET now accepts index_type, pq_m, ivf_cells, and
ivf_nprobe in addition to the existing m, m0, and ef_construction keys.

Quantization-shape parameters (index_type, pq_m, ivf_cells, ivf_nprobe)
dispatch VectorOp::SetParams to update the stored IndexConfig before the
index materializes. HNSW structure parameters (m, m0, ef_construction)
dispatch VectorOp::Rebuild as before. Both groups may appear in a single
ALTER and are dispatched independently; omitted fields preserve current
values.

The executor handler (execute_set_vector_params) is wired alongside the
existing Rebuild path, and integration tests cover HNSW-only, PQ-only,
IVF-PQ, and combined parameter updates.
@farhan-syah farhan-syah merged commit e5901c5 into main Apr 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CREATE VECTOR INDEX DSL has no quantization params — engine supports SQ8/PQ/IVF-PQ but unreachable from SQL

1 participant