Skip to content

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

Open
prajalg wants to merge 54 commits into
mainfrom
vector_support_v7
Open

feat(core): add VECTOR datatype support with Oracle vector integration#1
prajalg wants to merge 54 commits into
mainfrom
vector_support_v7

Conversation

@prajalg

@prajalg prajalg commented May 22, 2026

Copy link
Copy Markdown
Owner

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 VECTOR data type with configurable dimension and format, plus DataTypes.VECTOR export
    • Added vector similarity helper methods: cosineDistance, innerProduct, l1Distance, l2Distance, vectorDistance
    • Added VECTOR index support (Oracle): HNSW & IVF, including creation and validation
  • Enhancements

    • Expanded supported inputs to numeric typed arrays (including binary/Uint8Array) and sparse-vector objects (Oracle)
    • Improved Oracle VECTOR SQL/literal handling and “show indexes” metadata (version-aware)
  • Tests

    • Added extensive Oracle unit/integration and core unit test coverage for VECTOR types, validation, persistence, indexing, and vector distance queries

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 changed the title feat(core): add VECTOR datatype support and Oracle vector integration feat(core): add VECTOR datatype support with Oracle vector integration May 22, 2026
@prajalg prajalg force-pushed the vector_support_v7 branch from 993528c to 484a3d9 Compare May 28, 2026 08:17
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 75f1fb91-bf50-4aa1-9f05-f2366a6fd284

📥 Commits

Reviewing files that changed from the base of the PR and between f42eebe and 3fce97b.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • package.json

📝 Walkthrough

Walkthrough

Adds a VECTOR data type, Sequelize vector helpers, Oracle VECTOR SQL and index support, show-index metadata changes, and unit/integration tests. Also bumps the root esbuild devDependency.

Changes

VECTOR data type and Sequelize integration

Layer / File(s) Summary
Core VECTOR types and validation
packages/core/src/abstract-dialect/data-types.ts
Defines VectorOptions, NumericTypedArray, and VectorValue. Implements AbstractVECTORBase, concrete VECTOR format handling, and typed-array detection.
Dialect capability and public surface
packages/core/src/abstract-dialect/dialect.ts, packages/core/src/abstract-dialect/query-interface.d.ts, packages/core/src/data-types.ts
Adds the VECTOR capability flag, defaults it to false, expands IndexType to include VECTOR, and exports DataTypes.VECTOR.
Sequelize vector helper methods
packages/core/src/sequelize.d.ts, packages/core/src/sequelize.js
Adds cosineDistance, innerProduct, l1Distance, l2Distance, and vectorDistance with dialect VECTOR support checks and typed VectorValue inputs.

Oracle VECTOR support

Layer / File(s) Summary
Oracle VECTOR datatype and formatting
packages/oracle/src/_internal/data-types-overrides.ts, packages/oracle/src/dialect.ts, packages/oracle/src/query-generator.internal.ts
Adds Oracle VECTOR option and sparse-vector types, the Oracle VECTOR data type class, dense input conversion, bind definition, and Oracle VECTOR_DISTANCE literal formatting helpers.
Oracle VECTOR index generation
packages/oracle/src/query-generator.js
Extends Oracle index creation to build CREATE VECTOR INDEX statements, normalize VECTOR options, validate fields and parameters, and support HNSW and IVF modes.
Show-index metadata mapping
packages/oracle/src/query-generator-typescript.internal.ts, packages/oracle/src/query.js, packages/core/test/unit/query-generator/show-indexes-query.test.ts
Conditionally includes INDEX_SUBTYPE in Oracle showIndexesQuery, derives VECTOR index method/type from metadata, and updates show-index SQL expectations.

Tests and support

Layer / File(s) Summary
Core VECTOR unit tests
packages/core/test/unit/data-types/string-types.test.ts, packages/core/test/unit/sequelize.test.ts, test/esm-named-exports.test.js
Adds DataTypes.VECTOR unit coverage and tests vector helper behavior, including the ESM export ignore update.
Oracle VECTOR unit tests
packages/core/test/unit/dialects/oracle/query-generator.test.js, packages/core/test/unit/dialects/oracle/vector.test.js
Adds Oracle unit tests for VECTOR columns, index SQL, metadata mapping, datatype overrides, VECTOR_DISTANCE safety, and pagination behavior.
Oracle VECTOR integration tests
packages/core/test/integration/dialects/oracle/vector.test.js
Adds Oracle-gated integration tests for VECTOR persistence, similarity searches, literal handling, and index sync behavior.
Build dependency update
package.json
Bumps the root esbuild devDependency from 0.28.0 to 0.28.1.

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant Sequelize
  participant Dialect
  participant OracleQueryGeneratorInternal
  App->>Sequelize: vectorDistance(column, value)
  Sequelize->>Dialect: supports?.dataTypes?.VECTOR
  alt supported
    Dialect-->>Sequelize: true
    Sequelize->>OracleQueryGeneratorInternal: formatFn(VECTOR_DISTANCE, column, value)
    OracleQueryGeneratorInternal-->>Sequelize: fn expression
    Sequelize-->>App: Fn
  else unsupported
    Dialect-->>Sequelize: false
    Sequelize-->>App: Error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 I hopped through vectors, sharp and bright,
With HNSW trails and IVF in sight.
Typed arrays binked; Oracle sang,
VECTOR_DISTANCE gave a SQL clang.
A carrot toast to this rabbit’s delight!

🚥 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 matches the main change: adding VECTOR datatype support with Oracle integration.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vector_support_v7

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@packages/core/test/integration/dialects/oracle/vector.test.js`:
- Around line 404-406: The finally block unconditionally calls
IndexedItem.drop(), which can throw if the table was never created and mask the
real assertion failure; update the cleanup to guard the drop call by checking
existence or swallowing errors: wrap IndexedItem.drop() in a try/catch that
logs/ignores "table not found" errors (or use an API like
IndexedItem.exists()/hasTable() if available) so only genuine failures surface
while ensuring IndexedItem.drop() is still attempted when appropriate.

In `@packages/oracle/src/query-generator.internal.ts`:
- Around line 88-90: Update the VECTOR typed-array handling in `#formatVectorArg`
so it accepts the full set of numeric typed arrays used by core/base (match
packages/oracle/src/_internal/data-types-overrides.ts) instead of only
Float32Array, Float64Array, and Uint8Array: either import and call the existing
isNumericTypedArray (or reference BaseTypes.NumericTypedArray) to decide when to
call `#formatVectorFromIterable`, or expand the instanceof checks to include
Int8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, and
Uint32Array; ensure the conditional that calls
this.#formatVectorFromIterable(arg) is updated and keep or update the
error/validation message to clearly reflect the supported typed-array set.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d2bd3e7f-abb0-4ad9-830c-f8ca459c8c50

📥 Commits

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

📒 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

Comment thread packages/core/test/integration/dialects/oracle/vector.test.js
Comment on lines +88 to +90
if (arg instanceof Float32Array || arg instanceof Float64Array || arg instanceof Uint8Array) {
return this.#formatVectorFromIterable(arg);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 💤 Low value

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if Oracle oracledb driver documentation specifies which typed arrays are supported for VECTOR
rg -n "Float32Array|Float64Array|Uint8Array|Int8Array|Int16Array|Int32Array" packages/oracle/src --type ts -C2

Repository: prajalg/sequelize

Length of output: 2109


Expand Oracle VECTOR typed-array handling to match core/base numeric typed arrays

packages/oracle/src/query-generator.internal.ts formats only Float32Array, Float64Array, and Uint8Array at lines 88-90, but packages/oracle/src/_internal/data-types-overrides.ts treats BaseTypes.NumericTypedArray as including Int8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, and Uint32Array as well. This means callers can pass Oracle VECTOR validation and later hit a confusing failure in #formatVectorArg.

Update #formatVectorArg to use the same isNumericTypedArray logic (or expand the instanceof checks to cover the full NumericTypedArray set), or adjust the Oracle-side validation/error message to clearly state which typed arrays are actually supported for VECTOR distance functions.

🤖 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/query-generator.internal.ts` around lines 88 - 90, Update
the VECTOR typed-array handling in `#formatVectorArg` so it accepts the full set
of numeric typed arrays used by core/base (match
packages/oracle/src/_internal/data-types-overrides.ts) instead of only
Float32Array, Float64Array, and Uint8Array: either import and call the existing
isNumericTypedArray (or reference BaseTypes.NumericTypedArray) to decide when to
call `#formatVectorFromIterable`, or expand the instanceof checks to include
Int8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, and
Uint32Array; ensure the conditional that calls
this.#formatVectorFromIterable(arg) is updated and keep or update the
error/validation message to clearly reflect the supported typed-array set.

@prajalg

prajalg commented May 29, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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