BigQuery: support CREATE VECTOR INDEX - #2437
Open
moshap-firebolt wants to merge 1 commit into
Open
Conversation
BigQuery can create a vector index for approximate nearest-neighbor search over
an embedding column:
CREATE [OR REPLACE] VECTOR INDEX [IF NOT EXISTS] <name>
ON <table>(<column>)
OPTIONS(index_type = 'IVF', distance_type = 'COSINE', ...)
`VECTOR` is not a keyword, so `parse_create` previously failed with
`Expected: an object type after CREATE, found: VECTOR`.
### Changes
- Add `vector`, `or_replace` and `options` fields to `CreateIndex`. `VECTOR` is
a modifier on `CREATE INDEX` (like `EXTERNAL` on `CREATE TABLE`), so it reuses
the existing node rather than a new statement variant. `Display` renders
`CREATE [OR REPLACE ]VECTOR INDEX ...` plus a trailing `OPTIONS(...)`.
- Parse the form in `parse_create` via a small `parse_create_vector_index`
helper; the `OPTIONS(...)` clause reuses `parse_options` / `SqlOption`, so it
parses and renders the same way as `CREATE TABLE` / `CREATE VIEW` OPTIONS.
- Plain `CREATE INDEX` is unchanged (all three fields default to false/empty).
- New test `parse_bigquery_create_vector_index` in `tests/sqlparser_bigquery.rs`
verifies the round-trip and covers `OR REPLACE`, `IF NOT EXISTS`, multi-part
names and the OPTIONS-less form.
Docs: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_vector_index_statement
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BigQuery can create a vector index for approximate nearest-neighbor search over
an embedding column:
VECTORis not a keyword, soparse_createpreviously failed withExpected: an object type after CREATE, found: VECTOR.Changes
vector,or_replaceandoptionsfields toCreateIndex.VECTORisa modifier on
CREATE INDEX(likeEXTERNALonCREATE TABLE), so it reusesthe existing node rather than a new statement variant.
DisplayrendersCREATE [OR REPLACE ]VECTOR INDEX ...plus a trailingOPTIONS(...).parse_createvia a smallparse_create_vector_indexhelper; the
OPTIONS(...)clause reusesparse_options/SqlOption, so itparses and renders the same way as
CREATE TABLE/CREATE VIEWOPTIONS.CREATE INDEXis unchanged (all three fields default to false/empty).parse_bigquery_create_vector_indexintests/sqlparser_bigquery.rsverifies the round-trip and covers
OR REPLACE,IF NOT EXISTS, multi-partnames and the OPTIONS-less form.
Docs: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_vector_index_statement