refactor(Schema): simplify vector index SQL template#3959
Conversation
There was a problem hiding this comment.
Pull request overview
This PR simplifies the generated SQL template for creating vector indexes by relying on server-side autodetection for settings that no longer need to be emitted client-side.
Changes:
- Removes autodetected vector index settings from the SQL template, leaving only
distance=cosine. - Updates end-to-end query template expectations.
- Adds unit test coverage for the simplified vector index template.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/containers/Tenant/utils/schemaQueryTemplates.ts |
Simplifies addVectorIndex template settings. |
src/containers/Tenant/utils/__test__/schemaQueryTemplates.test.ts |
Adds unit coverage for the vector index template output. |
tests/suites/tenant/queryEditor/queryTemplates.test.ts |
Updates UI test expectations for the simplified template. |
|
@copilot I don't think we need all those tests for such a simple change. |
|
@copilot and name the PR according to commit-lint |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5db6d752d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| levels=\${5:2}, | ||
| clusters=\${6:128}, | ||
| overlap_clusters=\${7:3} | ||
| distance=cosine |
There was a problem hiding this comment.
Preserve vector-index settings for older clusters
When the UI is used against clusters that do not yet implement the new server-side autodetection, this template now generates an ALTER TABLE ... vector_kmeans_tree statement with only distance, while the docs URL embedded in the template still documents vector_type, vector_dimension, clusters, and levels in every vector-index example. In that environment, selecting “Add vector index” produces SQL that users must know how to repair manually, so please either keep the editable placeholders or gate the simplified form on a backend capability/version check.
Useful? React with 👍 / 👎.
Removed the new unit test block for |
Remove autodetected vector index settings (vector_type, vector_dimension, levels, clusters, overlap_clusters) from template, keeping only distance=cosine. Server-side autodetection now handles these parameters.
7c6666c to
3297216
Compare
Vector index creation templates were explicitly filling settings now supported by server-side autodetection. This made generated SQL noisier and could override intended defaults.
Template
distance=cosineas the only generated vector index setting.vector_type,vector_dimension,levels,clusters, andoverlap_clusters.Tests
distance=cosine.Greptile Summary
This PR simplifies the
addVectorIndexSQL template by removing five settings (vector_type,vector_dimension,levels,clusters,overlap_clusters) that are now handled by server-side autodetection, retaining only thedistance=cosineparameter that has no server-side default.schemaQueryTemplates.ts: TheaddVectorIndextemplateWITHblock is reduced to a singledistance=cosineentry, eliminating noisy placeholder snippets and avoiding unintentional override of server defaults.queryTemplates.test.ts) is updated to verify the simplified template containsdistance=cosine.Confidence Score: 5/5
Safe to merge — the change removes boilerplate from a SQL template string and has no impact on runtime logic or data flow.
The diff touches a single template string and one test file. The removal of the five WITH-clause parameters is intentional. No shared utilities, state, or API contracts are affected.
No files require special attention.
Important Files Changed
distance=cosine.distance=cosineis present in the simplified template.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["addVectorIndex(params?)"] --> B{params?.relativePath?} B -- yes --> C["path = normalised relativePath"] B -- no --> D["path = snippet placeholder"] C & D --> E["Build SQL template"] E --> F["ALTER TABLE {path}\nADD INDEX my_vector_index\nGLOBAL USING vector_kmeans_tree\nON (embedding)"] F --> G["WITH (\n distance=cosine\n)"] G --> H["Return SQL string"] style G fill:#d4edda,stroke:#28a745Reviews (1): Last reviewed commit: "Simplify vector index template settings" | Re-trigger Greptile
Greptile Summary
This PR simplifies the vector index SQL template by removing five auto-detected settings (
vector_type,vector_dimension,levels,clusters,overlap_clusters) and keeping onlydistance=cosine, relying on server-side autodetection for the rest.${1}through${3}).distance=cosine— it does not assert the absence of the removed settings, so re-introduction of any removed setting would go undetected.Confidence Score: 5/5
Safe to merge — the template change is a clean removal of settings now handled by the server, and the SQL output remains syntactically valid.
The only changed logic is stripping five WITH-clause parameters from a SQL snippet; the remaining
distance=cosineentry is correctly formatted with no trailing comma. The test update is straightforward and the E2E suite still exercises the template path.No files require special attention.
Important Files Changed
distance=cosine. Template syntax is valid and tab-stop numbering is now correct.overlap_clustersassertion with adistance=cosinecheck; does not add negative assertions to confirm removed settings are absent, which diverges from the stated "only contains distance setting" title.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[addVectorIndex called] --> B{params.relativePath set?} B -- Yes --> C[Use normalized table path] B -- No --> D[Use snippet placeholder] C --> E[Generate SQL template] D --> E E --> F["WITH (\n distance=cosine\n)"] F --> G[Server autodetects:\nvector_type, vector_dimension,\nlevels, clusters, overlap_clusters]Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "refactor(Schema): simplify vector index ..." | Re-trigger Greptile
CI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ✨1 🗑️1
✨ New Tests (1)
🗑️ Deleted Tests (1)
Bundle Size: ✅
Current: 64.02 MB | Main: 64.02 MB
Diff: 0.27 KB (-0.00%)
✅ Bundle size unchanged.
ℹ️ CI Information