Skip to content

refactor(Schema): simplify vector index SQL template#3959

Open
Copilot wants to merge 1 commit into
mainfrom
copilot/do-not-substitute-parameters
Open

refactor(Schema): simplify vector index SQL template#3959
Copilot wants to merge 1 commit into
mainfrom
copilot/do-not-substitute-parameters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

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

    • Keep distance=cosine as the only generated vector index setting.
    • Stop emitting autodetected vector_type, vector_dimension, levels, clusters, and overlap_clusters.
  • Tests

    • Update e2e query template test to verify simplified template contains distance=cosine.
ALTER TABLE table
ADD INDEX my_vector_index
GLOBAL USING vector_kmeans_tree
ON (embedding)
WITH (
    distance=cosine
);

Greptile Summary

This PR simplifies the addVectorIndex SQL template by removing five settings (vector_type, vector_dimension, levels, clusters, overlap_clusters) that are now handled by server-side autodetection, retaining only the distance=cosine parameter that has no server-side default.

  • schemaQueryTemplates.ts: The addVectorIndex template WITH block is reduced to a single distance=cosine entry, eliminating noisy placeholder snippets and avoiding unintentional override of server defaults.
  • Tests: The e2e test (queryTemplates.test.ts) is updated to verify the simplified template contains distance=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

Filename Overview
src/containers/Tenant/utils/schemaQueryTemplates.ts Removed five auto-detected parameters (vector_type, vector_dimension, levels, clusters, overlap_clusters) from the addVectorIndex SQL template, leaving only distance=cosine.
tests/suites/tenant/queryEditor/queryTemplates.test.ts E2E test updated to verify distance=cosine is 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:#28a745
Loading

Reviews (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 only distance=cosine, relying on server-side autodetection for the rest.

  • The template change is correct: the resulting SQL is valid, the trailing comma is properly removed, and snippet tab-stop numbering is now contiguous (${1} through ${3}).
  • The test is updated to match the new output, but the renamed test ("only contains distance setting") only asserts presence of 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=cosine entry 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

Filename Overview
src/containers/Tenant/utils/schemaQueryTemplates.ts Removes five auto-detected settings (vector_type, vector_dimension, levels, clusters, overlap_clusters) from the vector index SQL template, leaving only distance=cosine. Template syntax is valid and tab-stop numbering is now correct.
tests/suites/tenant/queryEditor/queryTemplates.test.ts Renames the vector index test and replaces the overlap_clusters assertion with a distance=cosine check; 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]
Loading

Fix All in Codex Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
tests/suites/tenant/queryEditor/queryTemplates.test.ts:247-249
The test name says "only contains distance setting" but the assertion only verifies that `distance=cosine` is present — it doesn't confirm the removed settings are absent. Adding negative assertions would make the test name accurate and prevent the removed settings from accidentally reappearing.

```suggestion
        const editorContent = await queryEditor.getEditorContent();
        expect(editorContent).toContain('distance=cosine');
        expect(editorContent).not.toContain('vector_type');
        expect(editorContent).not.toContain('vector_dimension');
        expect(editorContent).not.toContain('levels');
        expect(editorContent).not.toContain('clusters');
        expect(editorContent).not.toContain('overlap_clusters');
    });
```

Reviews (3): Last reviewed commit: "refactor(Schema): simplify vector index ..." | Re-trigger Greptile

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
678 669 0 6 3
Test Changes Summary ✨1 🗑️1

✨ New Tests (1)

  1. Add vector index template only contains distance setting (tenant/queryEditor/queryTemplates.test.ts)

🗑️ Deleted Tests (1)

  1. Add vector index template contains overlap_clusters parameter (tenant/queryEditor/queryTemplates.test.ts)

Bundle Size: ✅

Current: 64.02 MB | Main: 64.02 MB
Diff: 0.27 KB (-0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Copilot AI linked an issue May 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix auto-adding parameters for vector index Simplify vector index SQL template settings May 29, 2026
Copilot AI requested a review from adameat May 29, 2026 10:00
@adameat adameat marked this pull request as ready for review May 29, 2026 10:03
Copilot AI review requested due to automatic review settings May 29, 2026 10:03
@adameat adameat requested a review from kkdras as a code owner May 29, 2026 10:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@adameat
Copy link
Copy Markdown
Member

adameat commented May 29, 2026

@copilot I don't think we need all those tests for such a simple change.

@adameat
Copy link
Copy Markdown
Member

adameat commented May 29, 2026

@copilot and name the PR according to commit-lint

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 29, 2026

@copilot I don't think we need all those tests for such a simple change.

Removed the new unit test block for addVectorIndex and simplified the e2e test to just check that distance=cosine is present, dropping the verbose negative assertions.

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.
Copilot AI force-pushed the copilot/do-not-substitute-parameters branch from 7c6666c to 3297216 Compare May 29, 2026 10:14
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 29, 2026

@copilot and name the PR according to commit-lint

Updated commit message to follow conventional commit format: refactor(Schema): simplify vector index SQL template (3297216)

Copilot AI changed the title Simplify vector index SQL template settings refactor(Schema): simplify vector index SQL template May 29, 2026
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.

Do not substitute levels, clusters, vector_type and vector_dimensions

3 participants