Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(core): add VECTOR datatype support with Oracle vector integration#18227

Open
prajalg wants to merge 52 commits into
sequelize:mainsequelize/sequelize:mainfrom
prajalg:vector_support_v7prajalg/sequelize:vector_support_v7Copy head branch name to clipboard
Open

feat(core): add VECTOR datatype support with Oracle vector integration#18227
prajalg wants to merge 52 commits into
sequelize:mainsequelize/sequelize:mainfrom
prajalg:vector_support_v7prajalg/sequelize:vector_support_v7Copy head branch name to clipboard

Conversation

@prajalg
Copy link
Copy Markdown

@prajalg prajalg commented May 28, 2026

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description of Changes

This PR adds VECTOR support with Oracle-first implementation, shared core abstractions, and full validation/test coverage for vector SQL generation paths.

Core datatype & API groundwork

  • Added shared vector datatype foundation in core:
    • AbstractVECTORBase (shared behavior/validation)
    • generic DataTypes.VECTOR constructor overloads:
      • DataTypes.VECTOR
      • DataTypes.VECTOR(dimension)
      • DataTypes.VECTOR(dimension, format)
      • DataTypes.VECTOR({ dimension, format })
  • Added vector value validation for arrays and typed arrays.
  • Added dialect SQL rendering hooks for vector types.
  • Added Sequelize vector helper methods:
    • cosineDistance
    • innerProduct
    • l1Distance
    • l2Distance
    • vectorDistance
  • Updated typings so vector datatype + helper APIs are typed consistently.

Oracle integration

  • Enabled supports.dataTypes.VECTOR = true.
  • Added Oracle vector datatype override with Oracle-specific option handling and validation, including Oracle storage options (including SPARSE) and bind marshalling.
  • Extended Oracle query-generator/vector function mapping so Sequelize vector helpers resolve to Oracle-native SQL.
  • Added normalization/validation for vector-function arguments and supported input shapes.
  • Added Oracle vector index SQL generation and validations for:
    • using
    • distance
    • accuracy
    • parameters
    • per-field order
  • Hardened invalid/error-path handling (including unsafe/injection-like option fragments) with explicit allowlists.

Tests

  • Added/updated unit and integration tests for:
    • vector datatype constructor/rendering/validation paths
    • Oracle vector SQL generation paths
    • error paths for invalid/unsafe vector options
    • Oracle show-index compatibility behavior across version expectations

Guidance for other dialects

For future dialect integration, this PR establishes the recommended path:

  1. Enable supports.dataTypes.VECTOR.
  2. Reuse VECTOR where generic option shape is sufficient, or extend AbstractVECTORBase for dialect-specific option models.
  3. Implement dialect SQL rendering + bind handling.
  4. Map vector helper functions in query-generator.
  5. Add dialect-specific index/query support and validation.
  6. Mirror unit/integration coverage.

List of Breaking Changes

  • None.

Summary by CodeRabbit

  • New Features

    • Added a VECTOR data type with configurable dimensions/formats and dialect support flags
    • New vector helper methods for similarity/distance queries (cosine, inner product, L1, L2, generic)
  • Database

    • Oracle: support for VECTOR columns, VECTOR indexes creation/management, query generation and index metadata handling
  • Tests

    • Extensive unit and integration tests for VECTOR behavior, validation, SQL generation, bindings, queries, and indexing
  • Chores

    • Ignored VECTOR in ESM/CJS export comparison for compatibility

Review Change Stack

prajalg and others added 30 commits March 20, 2026 15:30
…etc.

validate using to only allow hnsw or ivf
allowlist distance metrics before emitting WITH DISTANCE
require numeric, finite, positive values for accuracy and vector index parameters
quote dropConstraintQuery constraint names
@prajalg prajalg requested a review from a team as a code owner May 28, 2026 03:06
@prajalg prajalg requested review from WikiRik and sdepold May 28, 2026 03:06
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8362d1e8-ce5e-4cca-8b11-8d0dee04d2b0

📥 Commits

Reviewing files that changed from the base of the PR and between 9f1579e and f42eebe.

📒 Files selected for processing (1)
  • packages/core/test/integration/dialects/oracle/vector.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/test/integration/dialects/oracle/vector.test.js

📝 Walkthrough

Walkthrough

This PR adds VECTOR datatype support across core and Oracle: core type contracts and export, Sequelize vector helper methods, Oracle-specific datatype overrides and SQL formatting, CREATE VECTOR INDEX generation, show-indexes projection updates, and comprehensive unit and integration tests.

Changes

Oracle Vector Data Type Support

Layer / File(s) Summary
Core Vector data type contracts and base implementation
packages/core/src/abstract-dialect/data-types.ts, packages/core/src/abstract-dialect/dialect.ts, packages/core/src/abstract-dialect/query-interface.d.ts, packages/core/src/data-types.ts
Shared VECTOR data type with VectorOptions interface, typed array definitions, abstract AbstractVECTORBase validating inputs and dialect support, concrete VECTOR class with dimension/format validation, IndexType extension, and public export via classToInvokable.
Sequelize vector helper APIs
packages/core/src/sequelize.d.ts, packages/core/src/sequelize.js
Adds instance helper methods (cosineDistance, innerProduct, l1Distance, l2Distance, vectorDistance) that guard dialect VECTOR support and return SQL fn(...) expressions; includes typings.
Oracle VECTOR data type override with sparse support
packages/oracle/src/_internal/data-types-overrides.ts, packages/oracle/src/dialect.ts
Oracle-specific VECTOR class with overloaded constructors, format/storage validation, sparse-vector object shape support, Float64Array coercion for dense inputs, DB_TYPE_VECTOR bind definition, and marks Oracle as supporting VECTOR.
Oracle vector SQL functions and literal formatting
packages/oracle/src/query-generator.internal.ts
Custom formatting for VECTOR functions and literals, VECTOR_DISTANCE argument validation/parsing, and helpers to render Oracle VECTOR('[...]') literals from arrays, typed arrays, or VECTOR('...') strings.
Oracle VECTOR index generation
packages/oracle/src/query-generator.js
Detects VECTOR index requests and generates CREATE VECTOR INDEX SQL; builds/sanitizes index options, supports HNSW/IVF parameters, validates fields and numeric options.
Show-indexes projection and version-aware detection
packages/oracle/src/query-generator-typescript.internal.ts, packages/oracle/src/query.js
Updates show-indexes SELECT projection to include index_type/index_subtype/ityp_name conditionally, adds version-detection helper, and maps INDEX_SUBTYPE to vector method (hnsw/ivf).
Core DataTypes.VECTOR unit tests
packages/core/test/unit/data-types/string-types.test.ts
Unit tests for VECTOR constructor, SQL rendering across dialects, and validation behavior.
Sequelize vector helper tests
packages/core/test/unit/sequelize.test.ts
Unit test covering sequelize.vectorDistance behavior depending on dialect VECTOR support.
Oracle unit tests
packages/core/test/unit/dialects/oracle/vector.test.js, packages/core/test/unit/dialects/oracle/query-generator.test.js
Comprehensive Oracle unit tests for CREATE TABLE VECTOR, index SQL generation/validation, show-indexes parsing, bind conversions, VECTOR_DISTANCE where generation, and pagination.
Oracle integration and show-indexes tests
packages/core/test/integration/dialects/oracle/vector.test.js, packages/core/test/unit/query-generator/show-indexes-query.test.ts
Integration tests validating retrieval, similarity searches, input validation, binary formats, index lifecycle, and updated showIndexesQuery expectations.
ESM and CJS exports compatibility
test/esm-named-exports.test.js
VECTOR added to the export ignore list for CJS/ESM parity checks.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • sdepold
  • ephys
  • WikiRik

Poem

🐰 I hopped through arrays and sparse delight,

Floats and binaries gleamed in Oracle's night,
HNSW leaps and IVFs in a row,
Distances sing and indices glow,
A rabbit cheers for VECTOR — swift and bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding VECTOR datatype support with Oracle vector integration. It accurately reflects the PR's primary objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/oracle/src/_internal/data-types-overrides.ts (1)

549-565: 💤 Low value

Redundant undefined check.

Number.isInteger(numDimensions) already returns false for undefined, making the numDimensions !== undefined check redundant.

Simplify the condition
   return (
     isVectorComponent(values) &&
     isVectorComponent(indices) &&
     Number.isInteger(numDimensions) &&
-    numDimensions !== undefined &&
     numDimensions > 0 &&
     values.length === indices.length
   );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/oracle/src/_internal/data-types-overrides.ts` around lines 549 -
565, In isOracleSparseVectorInput, remove the redundant numDimensions !==
undefined check from the return expression because
Number.isInteger(numDimensions) already handles undefined; update the return to
rely on Number.isInteger(numDimensions) && numDimensions > 0 (kept) along with
the existing isVectorComponent(values), isVectorComponent(indices) and
values.length === indices.length checks so behavior remains the same.
packages/core/test/unit/data-types/string-types.test.ts (1)

218-349: ⚡ Quick win

Avoid gating dialect-agnostic VECTOR tests behind dialect support.

Wrapping the whole suite in the support check skips constructor and validation coverage on non-VECTOR dialect runs. Keep dialect-independent tests always on, and gate only assertions that truly require native VECTOR SQL support.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/test/unit/data-types/string-types.test.ts` around lines 218 -
349, The current test file gates the entire DataTypes.VECTOR suite behind
sequelize.dialect.supports?.dataTypes?.VECTOR which hides constructor and
validate tests on dialects without native VECTOR; move the dialect-agnostic
describe blocks (the "constructor" and "validate" describes that call
DataTypes.VECTOR, type.validate, and expect validations) outside of the if block
so they always run, and keep only the dialect-specific "toSql" tests (the
testDataTypeSql calls for DataTypes.VECTOR and DataTypes.VECTOR(4) etc.) inside
the existing support check; update references to DataTypes.VECTOR and the
describe titles accordingly so constructor/validate tests run unconditionally
while SQL-generation tests remain gated.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/core/test/unit/data-types/string-types.test.ts`:
- Around line 218-349: The current test file gates the entire DataTypes.VECTOR
suite behind sequelize.dialect.supports?.dataTypes?.VECTOR which hides
constructor and validate tests on dialects without native VECTOR; move the
dialect-agnostic describe blocks (the "constructor" and "validate" describes
that call DataTypes.VECTOR, type.validate, and expect validations) outside of
the if block so they always run, and keep only the dialect-specific "toSql"
tests (the testDataTypeSql calls for DataTypes.VECTOR and DataTypes.VECTOR(4)
etc.) inside the existing support check; update references to DataTypes.VECTOR
and the describe titles accordingly so constructor/validate tests run
unconditionally while SQL-generation tests remain gated.

In `@packages/oracle/src/_internal/data-types-overrides.ts`:
- Around line 549-565: In isOracleSparseVectorInput, remove the redundant
numDimensions !== undefined check from the return expression because
Number.isInteger(numDimensions) already handles undefined; update the return to
rely on Number.isInteger(numDimensions) && numDimensions > 0 (kept) along with
the existing isVectorComponent(values), isVectorComponent(indices) and
values.length === indices.length checks so behavior remains the same.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a316a46-a0cb-4e2a-96cf-30d68fa37caf

📥 Commits

Reviewing files that changed from the base of the PR and between 8260c29 and 484a3d9.

📒 Files selected for processing (19)
  • packages/core/src/abstract-dialect/data-types.ts
  • packages/core/src/abstract-dialect/dialect.ts
  • packages/core/src/abstract-dialect/query-interface.d.ts
  • packages/core/src/data-types.ts
  • packages/core/src/sequelize.d.ts
  • packages/core/src/sequelize.js
  • packages/core/test/integration/dialects/oracle/vector.test.js
  • packages/core/test/unit/data-types/string-types.test.ts
  • packages/core/test/unit/dialects/oracle/query-generator.test.js
  • packages/core/test/unit/dialects/oracle/vector.test.js
  • packages/core/test/unit/query-generator/show-indexes-query.test.ts
  • packages/core/test/unit/sequelize.test.ts
  • packages/oracle/src/_internal/data-types-overrides.ts
  • packages/oracle/src/dialect.ts
  • packages/oracle/src/query-generator-typescript.internal.ts
  • packages/oracle/src/query-generator.internal.ts
  • packages/oracle/src/query-generator.js
  • packages/oracle/src/query.js
  • test/esm-named-exports.test.js

@prajalg prajalg force-pushed the vector_support_v7 branch from 993528c to 484a3d9 Compare May 28, 2026 08:17
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.