Skip to content

Conversation

@alumni
Copy link
Collaborator

@alumni alumni commented Jun 12, 2025

Description of change

Add support for REAL_VECTOR and HALF_VECTOR in SAP HANA Cloud. Optional parameter: length, for a fixed-length vector.

Usage:

@Column('real_vector')
embeddings: Buffer;

or, with the connection option vectorOutputType=Array:

@Column('real_vector')
embeddings: number[];

Further Documentation:

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change

Summary by CodeRabbit

  • New Features
    • Added support for SAP HANA Cloud vector column types real_vector and half_vector, including schema and persistence capabilities for both array and buffer representations.
  • Documentation
    • Updated SAP column type documentation to clarify supported types, deprecations, and added usage guidance for new vector types with links to official SAP resources.
  • Bug Fixes
    • Improved type handling for SAP columns, including updates to supported data types and default values.
  • Tests
    • Introduced comprehensive tests for new vector column types, covering both array and buffer storage, and modernized existing SAP column type tests for clarity and reliability.
  • Chores
    • Upgraded @sap/hana-client dependency to the latest version.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

Support for SAP HANA vector column types (real_vector, half_vector) was added, including schema and data type handling in the driver, type definitions, and documentation. Tests and entity definitions were updated to cover these new types, with additional improvements to test style and validation logic. Package dependencies were updated.

Changes

Files/Groups Change Summary
docs/docs/entity/1-entities.md Updated SAP column type documentation: clarified differences between HANA 2.0 and Cloud, added links, listed new vector types, described conversion and client behavior for real_vector/half_vector.
src/driver/sap/SapDriver.ts Expanded and reordered supported data types, added vector types, updated type normalization to map vector types to varbinary, changed length/scale type arrays, updated type defaults, and removed special Boolean/Number handling in value preparation.
src/driver/types/ColumnTypes.ts Added "half_vector" and "real_vector" to SAP length column types, allowed "timestamp" precision for SAP.
test/functional/database-schema/column-types/sap/column-types-sap.ts Refactored tests: renamed variables, switched from .should to expect, used repository .create(), improved type safety, and updated assertions.
test/functional/database-schema/column-types/sap/entity/Post.ts Removed dateObj and timeObj properties (typed as Date) from the entity; consolidated imports.
test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts
test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts
Consolidated import statements; no changes to class definitions or properties.
src/metadata-builder/EntityMetadataValidator.ts Replaced indexOf with includes for type checking; removed an unused empty loop.
package.json Updated @sap/hana-client devDependency version from ^2.24.21 to ^2.25.22.
test/functional/database-schema/vectors/sap/entity/ArrayEmbedding.ts Added new ArrayEmbedding entity: includes real_vector columns for small, large, and variable-length numeric arrays.
test/functional/database-schema/vectors/sap/entity/BufferEmbedding.ts Added new BufferEmbedding entity: includes a real_vector column stored as a Buffer.
test/functional/database-schema/vectors/sap/sap-vector.ts New test suite for SAP vector columns: tests schema, persistence, and hydration for both array and buffer vector representations, including custom serialization/deserialization logic.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant TypeORM as TypeORM
    participant SapDriver as SAP Driver
    participant SAPDB as SAP HANA DB

    App->>TypeORM: Define entity with real_vector/half_vector columns
    TypeORM->>SapDriver: Prepare schema (synchronize)
    SapDriver->>SAPDB: Create table with vector columns
    App->>TypeORM: Save entity with vector data
    TypeORM->>SapDriver: Prepare persistent value (array/buffer)
    SapDriver->>SAPDB: INSERT with vector data
    App->>TypeORM: Load entity
    TypeORM->>SapDriver: Hydrate value (array/buffer)
    SapDriver->>SAPDB: SELECT vector columns
    SAPDB-->>SapDriver: Return vector data (Buffer)
    SapDriver-->>TypeORM: Convert to array (if configured)
    TypeORM-->>App: Return hydrated entity
Loading

Suggested labels

new feature

Suggested reviewers

  • gioboa
  • naorpeled

Poem

In the fields of SAP, new vectors now grow,
With arrays and buffers, our data can flow.
From docs to the driver, the types are in line,
Entities and tests all sparkle and shine.
A hop, a leap, with each schema update—
This rabbit’s delighted to celebrate! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-21T18_04_45_887Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@alumni alumni requested a review from naorpeled June 12, 2025 23:55
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 12, 2025

typeorm-sql-js-example

npm i https://pkg.pr.new/typeorm/typeorm@11526

commit: e98394f

Copy link
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.

Actionable comments posted: 3

🧹 Nitpick comments (5)
docs/docs/entity/1-entities.md (1)

406-408: Remove blank line inside blockquote
Eliminate the empty line between the two > lines to comply with markdownlint (MD028).

@@ -407,1 +407,0
- 
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

407-407: Blank line inside blockquote
null

(MD028, no-blanks-blockquote)

test/functional/database-schema/column-types/sap/entity/Embedding.ts (2)

5-6: Consider using @PrimaryGeneratedColumn instead of manual IDs

Unless you intentionally need to supply the id yourself, using @PrimaryGeneratedColumn() avoids manual bookkeeping and prevents accidental PK collisions.


11-13: metadata looks like JSON – leverage simple-json

If the column will always hold JSON, declaring @Column("simple-json") gives automatic (de)serialization and saves future consumers from string parsing.

test/functional/database-schema/column-types/sap/column-types-sap.ts (1)

356-368: Use .include for partial-object assertions

Earlier in this file you rely on expect(obj).to.include({...}); here you switched to .contain. While Chai aliases the two, sticking to one style improves readability and avoids confusion for new contributors.

src/driver/sap/SapDriver.ts (1)

175-176: Why allow scale but not precision for timestamp?

TIMESTAMP(p) in SAP HANA supports precision; you added it only to withScaleColumnTypes. Consider adding it to withPrecisionColumnTypes for completeness.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42913b9 and 2188cc9.

📒 Files selected for processing (8)
  • docs/docs/entity/1-entities.md (1 hunks)
  • src/driver/sap/SapDriver.ts (6 hunks)
  • src/driver/types/ColumnTypes.ts (2 hunks)
  • test/functional/database-schema/column-types/sap/column-types-sap.ts (2 hunks)
  • test/functional/database-schema/column-types/sap/entity/Embedding.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/Post.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/driver/sap/SapDriver.ts (1)
src/driver/types/ColumnTypes.ts (1)
  • ColumnType (216-225)
🪛 LanguageTool
docs/docs/entity/1-entities.md

[uncategorized] ~404-~404: Loose punctuation mark.
Context: ... ### Column types forsap tinyint, smallint, integer, bigint, small...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)
docs/docs/entity/1-entities.md

407-407: Blank line inside blockquote
null

(MD028, no-blanks-blockquote)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: database-tests-compose (18) / sap
  • GitHub Check: database-tests (20) / mssql (^10.0.1)
  • GitHub Check: database-tests (20) / mssql (^9.1.1)
  • GitHub Check: database-tests (20) / mssql (^11.0.1)
  • GitHub Check: database-tests (18) / sqlite
  • GitHub Check: database-tests (20) / mongodb
  • GitHub Check: database-tests-windows / sqljs
  • GitHub Check: database-tests (18) / mssql (^9.1.1)
  • GitHub Check: database-tests (18) / sqljs
  • GitHub Check: database-tests (18) / better-sqlite3
  • GitHub Check: database-tests (18) / mssql (^11.0.1)
  • GitHub Check: database-tests (18) / mssql (^10.0.1)
  • GitHub Check: database-tests (18) / mongodb
  • GitHub Check: database-tests (18) / cockroachdb
  • GitHub Check: database-tests (18) / mysql_mariadb
  • GitHub Check: database-tests (18) / postgres (17-3.5)
  • GitHub Check: database-tests (18) / postgres (14-3.5)
  • GitHub Check: database-tests-windows / sqlite
  • GitHub Check: database-tests-windows / better-sqlite3
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts (1)

1-1: Consolidate imports for consistency
Combined the decorator imports into a single line, matching the style used across other SAP entity tests.

test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts (1)

1-1: Consolidated imports for consistency
Merged Entity, PrimaryColumn, and Column imports into one line to align with the import style in related test files.

src/driver/types/ColumnTypes.ts (2)

49-51: Extend WithPrecisionColumnType with timestamp
The addition of "timestamp" correctly enables precision-based timestamp support across SAP and other platforms.


78-78: Add real_vector to WithLengthColumnType
Introduces the SAP-specific real_vector type into the length-based union, matching driver and documentation updates.

test/functional/database-schema/column-types/sap/entity/Post.ts (1)

1-1: Consolidate imports for consistency
Unified the decorator imports into a single line, consistent with other SAP entity test files.

docs/docs/entity/1-entities.md (1)

404-404: Include real_vector in SAP column types list
Adds the new real_vector data type to the SAP column types enumeration, reflecting the newly supported vector type.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~404-~404: Loose punctuation mark.
Context: ... ### Column types forsap tinyint, smallint, integer, bigint, small...

(UNLIKELY_OPENING_PUNCTUATION)

src/driver/sap/SapDriver.ts (2)

494-513: Removed Boolean coercion – double-check backward compatibility

Old code converted booleans to 1/0; now raw true/false is sent. Ensure all supported SAP HANA versions accept literal booleans in INSERT/UPDATE, otherwise migrations on older DBs may break.


614-619: Good fallback for real_vector, but document it

Mapping real_vectorblob on (< 4.0) clusters is sound; add a comment or doc entry so users understand why queries show blob after sync.

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Nice PR @alumni 👏 some tests are failing though

@alumni
Copy link
Collaborator Author

alumni commented Jun 13, 2025

Yes, I used BLOB as fallback for REAL_VECTOR if it's not supported, but BLOB doesn't allow a length option, while REAL_VECTOR does, so validation fails.

I will remove the fallback since I cannot find another alternative and dynamically register the entity.

@alumni alumni force-pushed the feature/sap-hana-real-vector branch 2 times, most recently from bb39eb2 to ecd9b4b Compare June 18, 2025 13:45
Copy link
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.

Actionable comments posted: 0

🧹 Nitpick comments (3)
docs/docs/entity/1-entities.md (1)

406-409: Remove the blank line inside the quoted note (MD028)

A blank line immediately after the opening > breaks the block-quote and is flagged by markdownlint.

-> Note 2: SAP HANA Cloud introduced the `real_vector` data type …
-
 > Note 2: SAP HANA Cloud introduced the `real_vector` data type …
test/functional/database-schema/vector-columns/sap/sap-real-vector.ts (2)

13-14: Drop the async keyword from describe callbacks

Mocha ignores promises returned by describe bodies; marking them async is misleading and may surface unhandled-rejection warnings in future Mocha versions.

-describe("real_vector with output type Array", async () => {
+describe("real_vector with output type Array", () => {-describe("real_vector with output type Buffer", async () => {
+describe("real_vector with output type Buffer", () => {

Also applies to: 107-108


118-144: Minor: prefer Float32Array for (de)serialising vectors

Using typed arrays avoids the explicit byte-loop and is easier to read:

-function deserializeFvecs(buffer: Buffer) {
-    const dataView = new DataView(
-        buffer.buffer,
-        buffer.byteOffset,
-        buffer.byteLength,
-    )
-    const length = dataView.getUint32(0, true)
-    const array = new Array<number>(length)
-    for (let index = 0; index < length; index++) {
-        array[index] = dataView.getFloat32(4 + index * 4, true)
-    }
-    return array
-}
+function deserializeFvecs(buffer: Buffer) {
+    const view = new DataView(buffer.buffer, buffer.byteOffset)
+    const length = view.getUint32(0, true)
+    return Array.from(
+        new Float32Array(buffer.buffer, buffer.byteOffset + 4, length),
+    )
+}-function serializeFvecs(array: number[]) {
-    const length = array.length
-    const arrayBuffer = new ArrayBuffer(4 + length * 4)
-    const dataView = new DataView(arrayBuffer)
-    dataView.setUint32(0, length, true)
-    for (let index = 0; index < length; index++) {
-        dataView.setFloat32(4 + index * 4, array[index], true)
-    }
-    return Buffer.from(arrayBuffer)
-}
+function serializeFvecs(values: number[]) {
+    const buffer = Buffer.alloc(4 + values.length * 4)
+    buffer.writeUInt32LE(values.length, 0)
+    new Float32Array(buffer.buffer, buffer.byteOffset + 4, values.length).set(
+        values,
+    )
+    return buffer
+}

Purely a readability / micro-perf tweak – feel free to ignore.

Also applies to: 133-144

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e9ab87 and ecd9b4b.

📒 Files selected for processing (11)
  • docs/docs/entity/1-entities.md (1 hunks)
  • src/driver/sap/SapDriver.ts (6 hunks)
  • src/driver/types/ColumnTypes.ts (2 hunks)
  • src/metadata-builder/EntityMetadataValidator.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/column-types-sap.ts (2 hunks)
  • test/functional/database-schema/column-types/sap/entity/Post.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/FvecsEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/sap-real-vector.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts
  • src/metadata-builder/EntityMetadataValidator.ts
  • src/driver/types/ColumnTypes.ts
  • test/functional/database-schema/column-types/sap/entity/Post.ts
  • test/functional/database-schema/column-types/sap/column-types-sap.ts
  • src/driver/sap/SapDriver.ts
🧰 Additional context used
🧬 Code Graph Analysis (3)
test/functional/database-schema/vector-columns/sap/entity/FvecsEmbedding.ts (3)
test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (1)
  • Entity (3-27)
src/decorator/columns/PrimaryColumn.ts (1)
  • PrimaryColumn (37-100)
src/decorator/columns/Column.ts (1)
  • Column (134-220)
test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (3)
test/functional/database-schema/vector-columns/sap/entity/FvecsEmbedding.ts (1)
  • Entity (3-16)
src/decorator/columns/PrimaryColumn.ts (1)
  • PrimaryColumn (37-100)
src/decorator/columns/Column.ts (1)
  • Column (134-220)
test/functional/database-schema/vector-columns/sap/sap-real-vector.ts (3)
test/utils/test-utils.ts (3)
  • createTestingConnections (388-482)
  • reloadTestingDatabases (500-505)
  • closeTestingConnections (487-495)
src/driver/DriverUtils.ts (1)
  • DriverUtils (8-297)
src/common/DeepPartial.ts (1)
  • DeepPartial (4-14)
🪛 LanguageTool
docs/docs/entity/1-entities.md

[uncategorized] ~404-~404: Loose punctuation mark.
Context: ... ### Column types forsap tinyint, smallint, integer, bigint, small...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)
docs/docs/entity/1-entities.md

407-407: Blank line inside blockquote
null

(MD028, no-blanks-blockquote)

⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: tests-linux (20) / sqljs
  • GitHub Check: tests-linux (20) / sqlite
  • GitHub Check: tests-linux (20) / mysql_mariadb
  • GitHub Check: tests-linux (20) / mssql
  • GitHub Check: tests-linux (20) / mongodb
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (18) / sqlite
  • GitHub Check: tests-linux (18) / postgres (14-3.5)
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / postgres (17-3.5)
  • GitHub Check: tests-linux (18) / better-sqlite3
  • GitHub Check: tests-linux (18) / sqljs
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-linux (18) / mongodb
  • GitHub Check: tests-windows / sqljs
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
docs/docs/entity/1-entities.md (1)

404-404: real_vector addition looks correct

The new data-type is appended consistently with the existing, comma-separated list and ends the sentence with a full stop – no functional or stylistic issues here.

test/functional/database-schema/vector-columns/sap/entity/FvecsEmbedding.ts (1)

1-16: Entity definition is minimal and correct

Primary key, text columns and the binary real_vector column are declared properly; synchronize: false matches other schema tests.

test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (1)

14-27: Well-structured column sampling

Small, large (nullable) and variable-length vectors give the test suite good coverage. Implementation LGTM.

@alumni alumni force-pushed the feature/sap-hana-real-vector branch from ecd9b4b to 9237a57 Compare June 18, 2025 14:02
Copy link
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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/docs/entity/1-entities.md (1)

409-409: Fix duplicated word and gerund usage
Remove the repeated “the” and switch to a gerund for smoother phrasing.

- TypeORM's `SapDriver` supports `tinyint`, `smallint`, `integer`, `bigint`, `smalldecimal`, `decimal`, `real`, `double`, `date`, `time`, `seconddate`, `timestamp`, `boolean`, `char`, `nchar`, `varchar`, `nvarchar`, `text`, `alphanum`, `shorttext`, `array`, `varbinary`, `blob`, `clob`, `nclob`, `st_geometry`, `st_point`, `real_vector`. Some of these are deprecated or removed in SAP HANA Cloud, and will be converted to the closest available alternative when connected to a Cloud database. We strongly suggest to use the data types native the the version of HANA you are using.
+ TypeORM's `SapDriver` supports `tinyint`, `smallint`, `integer`, `bigint`, `smalldecimal`, `decimal`, `real`, `double`, `date`, `time`, `seconddate`, `timestamp`, `boolean`, `char`, `nchar`, `varchar`, `nvarchar`, `text`, `alphanum`, `shorttext`, `array`, `varbinary`, `blob`, `clob`, `nclob`, `st_geometry`, `st_point`, `real_vector`. Some of these types are deprecated or removed in SAP HANA Cloud and will be converted to the closest available alternative when connected to a Cloud database. We strongly suggest using data types native to the version of HANA you are using.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecd9b4b and 9237a57.

📒 Files selected for processing (6)
  • docs/docs/entity/1-entities.md (1 hunks)
  • src/driver/sap/SapDriver.ts (6 hunks)
  • test/functional/database-schema/column-types/sap/column-types-sap.ts (2 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/FvecsEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/sap-real-vector.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • test/functional/database-schema/vector-columns/sap/entity/FvecsEmbedding.ts
  • test/functional/database-schema/column-types/sap/column-types-sap.ts
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts
  • test/functional/database-schema/vector-columns/sap/sap-real-vector.ts
  • src/driver/sap/SapDriver.ts
🧰 Additional context used
🪛 LanguageTool
docs/docs/entity/1-entities.md

[grammar] ~409-~409: The verb ‘suggest’ is used with the gerund form.
Context: ...nected to a Cloud database. We strongly suggest to use the data types native the the version o...

(ADMIT_ENJOY_VB)


[duplication] ~409-~409: Possible typo: you repeated a word.
Context: ...ly suggest to use the data types native the the version of HANA you are using. The `re...

(ENGLISH_WORD_REPEAT_RULE)


[uncategorized] ~411-~411: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ta type was introduced in SAP HANA Cloud and it is usable since `@sap/hana-client@2....

(COMMA_COMPOUND_SENTENCE)

⏰ Context from checks skipped due to timeout of 90000ms (18)
  • GitHub Check: tests-linux (20) / sap
  • GitHub Check: tests-linux (20) / sqljs
  • GitHub Check: tests-linux (20) / postgres (17-3.5)
  • GitHub Check: tests-linux (20) / mongodb
  • GitHub Check: tests-linux (18) / better-sqlite3
  • GitHub Check: tests-linux (20) / better-sqlite3
  • GitHub Check: tests-linux (20) / cockroachdb
  • GitHub Check: tests-linux (18) / postgres (14-3.5)
  • GitHub Check: tests-linux (18) / mongodb
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (18) / sqljs
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / postgres (17-3.5)
  • GitHub Check: tests-linux (18) / sqlite
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
docs/docs/entity/1-entities.md (1)

404-408: Great addition of SAP HANA 2.0 and Cloud links.
The newly added references to the official SAP Help pages will guide users to the authoritative source for data type differences.

@coveralls
Copy link

coveralls commented Jun 18, 2025

Coverage Status

coverage: 76.377% (-0.006%) from 76.383%
when pulling e98394f on alumni:feature/sap-hana-real-vector
into f2d2236 on typeorm:master.

@alumni alumni changed the title feat(sap): add support for REAL_VECTOR data type in SAP HANA Cloud feat(sap): add support for REAL_VECTOR and HALF_VECTOR data types in SAP HANA Cloud Jun 18, 2025
Copy link
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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
docs/docs/entity/1-entities.md (1)

409-412: Still missing the length option example & minor grammar nit

The earlier review already asked to document how to fix the vector length:

@Column("real_vector", { length: 1024 })
embeddings: number[];

That snippet is still absent. Also, add a comma before “and”:

“…introduced in SAP HANA Cloud, and it is usable…”

Please incorporate the example to make the feature discoverable.

🧹 Nitpick comments (2)
package.json (1)

239-239: packageManager lock-in: verify CI & release tooling

Locking the repo to pnpm@9.15.9 is fine, but ensure:

  1. All CI jobs and release pipelines already use this exact pnpm version (including SHA).
  2. Team onboarding docs mention the change.
  3. corepack enable is run in pre-install hooks for reproducibility.

Otherwise builds may break on older Node setups.

test/functional/database-schema/vector-columns/sap/sap-vector.ts (1)

51-65: variableVector length assertion is driver-specific

Column.length may be null, undefined, or "" depending on dialect implementation.
Hard-coding "" will make the test brittle across driver versions.

-expect(table.findColumnByName("variableVector")).to.contain({
-    type: "real_vector",
-    length: "",
-})
+const variableCol = table.findColumnByName("variableVector")!
+expect(variableCol.type).to.equal("real_vector")
+expect(variableCol.length ?? "").to.equal("")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9237a57 and 1248086.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • docs/docs/entity/1-entities.md (1 hunks)
  • package.json (2 hunks)
  • src/driver/sap/SapDriver.ts (6 hunks)
  • src/driver/types/ColumnTypes.ts (2 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/BufferEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/sap-vector.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/driver/types/ColumnTypes.ts
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts
  • src/driver/sap/SapDriver.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/functional/database-schema/vector-columns/sap/sap-vector.ts (3)
test/utils/test-utils.ts (3)
  • createTestingConnections (388-482)
  • reloadTestingDatabases (500-505)
  • closeTestingConnections (487-495)
src/driver/DriverUtils.ts (1)
  • DriverUtils (8-297)
src/common/DeepPartial.ts (1)
  • DeepPartial (4-14)
🪛 LanguageTool
docs/docs/entity/1-entities.md

[uncategorized] ~411-~411: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ta type was introduced in SAP HANA Cloud and it is usable since `@sap/hana-client@2....

(COMMA_COMPOUND_SENTENCE)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: tests-linux (20) / mysql_mariadb
  • GitHub Check: tests-linux (20) / better-sqlite3
  • GitHub Check: tests-linux (20) / sqlite
  • GitHub Check: tests-linux (20) / mssql
  • GitHub Check: tests-linux (20) / postgres (14-3.5)
  • GitHub Check: tests-linux (20) / cockroachdb
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (20) / mongodb
  • GitHub Check: tests-linux (18) / sqljs
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / postgres (14-3.5)
  • GitHub Check: tests-linux (18) / sqlite
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-windows / sqljs
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-linux (18) / better-sqlite3
  • GitHub Check: tests-linux (18) / mongodb
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
package.json (1)

109-113: Align peer-dependency floor with the newly required client version

@sap/hana-client is bumped to ^2.25.22 in devDependencies, but the peerDependencies floor is still ^2.12.25.
All functional tests introduced here (vector types, esp. half_vector) require >= 2.25.x. Leaving the lower range in peerDependencies will let downstream projects install a version that does not support these types and fail at runtime.

-    "@sap/hana-client": "^2.12.25",
+    "@sap/hana-client": "^2.25.22",

Please update the peer range – or, if full backward-compatibility is intended, guard the new driver logic with explicit version checks.

test/functional/database-schema/vector-columns/sap/entity/BufferEmbedding.ts (1)

1-16: Looks good – minimal, readable entity definition

The entity maps the new real_vector type correctly and keeps tests focused.

test/functional/database-schema/vector-columns/sap/sap-vector.ts (2)

112-120: synchronize flag is misplaced

driverSpecific.synchronize is ignored by createTestingConnections; the flag belongs
at the root of the DataSource options. This test happens to call synchronize() later,
but the intention is unclear. Move it one level up for clarity.


125-151: Helper (de)serialisers – good & self-contained

The FVEC helpers correctly marshal length-prefixed float32 arrays and keep the test
independent from external libs.

@alumni alumni force-pushed the feature/sap-hana-real-vector branch from 1248086 to b0d5a00 Compare June 18, 2025 15:16
@alumni alumni force-pushed the feature/sap-hana-real-vector branch from b0d5a00 to 2998ced Compare June 18, 2025 16:05
@alumni alumni force-pushed the feature/sap-hana-real-vector branch from 2998ced to 512c365 Compare June 21, 2025 17:57
@alumni alumni requested review from OSA413 and sgarner June 21, 2025 17:59
Copy link
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.

Actionable comments posted: 0

♻️ Duplicate comments (1)
docs/docs/entity/1-entities.md (1)

411-412: Document the length option for vector types.

Users should know they can specify a fixed vector size. Please add an example showing the { length: 1024 } option in the @Column("real_vector", { length: 1024 }) decorator, as previously suggested.

🧹 Nitpick comments (1)
docs/docs/entity/1-entities.md (1)

411-411: Fix missing preposition.

Insert "of" after "versions" for grammatical correctness:

- The `real_vector` and `half_vector` data types were introduced in recent versions SAP HANA Cloud (2024Q1 and 2025Q2 respectively)...
+ The `real_vector` and `half_vector` data types were introduced in recent versions of SAP HANA Cloud (2024Q1 and 2025Q2 respectively)...
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2998ced and 512c365.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • docs/docs/entity/1-entities.md (1 hunks)
  • package.json (1 hunks)
  • src/driver/sap/SapDriver.ts (7 hunks)
  • src/driver/types/ColumnTypes.ts (2 hunks)
  • src/metadata-builder/EntityMetadataValidator.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/column-types-sap.ts (2 hunks)
  • test/functional/database-schema/column-types/sap/entity/Post.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts (1 hunks)
  • test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/entity/BufferEmbedding.ts (1 hunks)
  • test/functional/database-schema/vector-columns/sap/sap-vector.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • test/functional/database-schema/column-types/sap/entity/PostWithoutTypes.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • test/functional/database-schema/column-types/sap/entity/PostWithOptions.ts
  • package.json
  • src/metadata-builder/EntityMetadataValidator.ts
  • test/functional/database-schema/vector-columns/sap/entity/BufferEmbedding.ts
  • src/driver/types/ColumnTypes.ts
  • test/functional/database-schema/column-types/sap/entity/Post.ts
  • test/functional/database-schema/column-types/sap/column-types-sap.ts
  • test/functional/database-schema/vector-columns/sap/sap-vector.ts
  • test/functional/database-schema/vector-columns/sap/entity/ArrayEmbedding.ts
  • src/driver/sap/SapDriver.ts
🧰 Additional context used
🪛 LanguageTool
docs/docs/entity/1-entities.md

[uncategorized] ~411-~411: Possible missing preposition found.
Context: ...ypes were introduced in recent versions SAP HANA Cloud (2024Q1 and 2025Q2 respectiv...

(AI_HYDRA_LEO_MISSING_OF)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: tests-linux (20) / postgres (14-3.5)
  • GitHub Check: tests-linux (20) / sqlite
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (20) / mssql
  • GitHub Check: tests-linux (20) / mysql_mariadb
  • GitHub Check: tests-linux (20) / cockroachdb
  • GitHub Check: tests-linux (18) / sqljs
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (20) / sqljs
  • GitHub Check: tests-linux (20) / sap
  • GitHub Check: tests-linux (20) / mongodb
  • GitHub Check: tests-linux (18) / better-sqlite3
  • GitHub Check: tests-linux (18) / postgres (17-3.5)
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-linux (18) / mongodb
  • GitHub Check: tests-windows / sqljs
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
docs/docs/entity/1-entities.md (2)

404-408: Approve documentation updates.

The section introducing SAP HANA 2.0 vs Cloud data types and the links are clear and accurate.


409-410: Approve supported data types list.

Inclusion of real_vector and half_vector in the SapDriver list is correct and aligns with the feature implementation.

@alumni alumni force-pushed the feature/sap-hana-real-vector branch from 512c365 to e98394f Compare June 21, 2025 18:03
Copy link
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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/functional/database-schema/vectors/sap/sap-vector.ts (1)

31-38: Consider adding error handling for unsupported driver versions.

While the driver version check correctly skips tests for versions < 4.0, consider adding a console warning or test skip message to make it clear why tests are being skipped in CI environments.

                    if (
                        !DriverUtils.isReleaseVersionOrGreater(
                            dataSource.driver,
                            "4.0",
                        )
                    ) {
+                        console.warn("Skipping SAP vector tests - driver version < 4.0 required")
                        return
                    }

Also applies to: 153-160

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 512c365 and e98394f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • docs/docs/entity/1-entities.md (1 hunks)
  • package.json (1 hunks)
  • src/driver/sap/SapDriver.ts (7 hunks)
  • src/driver/types/ColumnTypes.ts (2 hunks)
  • test/functional/database-schema/column-types/sap/column-types-sap.ts (2 hunks)
  • test/functional/database-schema/vectors/sap/entity/ArrayEmbedding.ts (1 hunks)
  • test/functional/database-schema/vectors/sap/entity/BufferEmbedding.ts (1 hunks)
  • test/functional/database-schema/vectors/sap/sap-vector.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • test/functional/database-schema/vectors/sap/entity/ArrayEmbedding.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • package.json
  • src/driver/types/ColumnTypes.ts
  • test/functional/database-schema/column-types/sap/column-types-sap.ts
  • docs/docs/entity/1-entities.md
  • src/driver/sap/SapDriver.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/functional/database-schema/vectors/sap/entity/BufferEmbedding.ts (3)
test/functional/database-schema/vectors/sap/entity/ArrayEmbedding.ts (1)
  • Entity (3-27)
src/decorator/columns/PrimaryColumn.ts (1)
  • PrimaryColumn (37-100)
src/decorator/columns/Column.ts (1)
  • Column (134-220)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: tests-linux (18) / postgres (17-3.5)
  • GitHub Check: tests-linux (18) / better-sqlite3
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-linux (20) / oracle
  • GitHub Check: tests-linux (20) / postgres (14-3.5)
  • GitHub Check: tests-linux (20) / postgres (17-3.5)
  • GitHub Check: tests-linux (20) / better-sqlite3
  • GitHub Check: tests-linux (20) / sqlite
  • GitHub Check: tests-linux (20) / mysql_mariadb
  • GitHub Check: tests-linux (20) / sqljs
  • GitHub Check: tests-linux (20) / mssql
  • GitHub Check: tests-linux (20) / cockroachdb
  • GitHub Check: tests-linux (20) / mongodb
  • GitHub Check: tests-linux (20) / sap
  • GitHub Check: tests-windows / sqljs
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
test/functional/database-schema/vectors/sap/entity/BufferEmbedding.ts (1)

1-16: LGTM! Clean entity definition for SAP vector support.

The BufferEmbedding entity is well-structured and correctly implements the new real_vector column type for SAP HANA Cloud. The use of Buffer type for the vector column aligns with the binary storage format, and the variable-length vector approach (no length specification) provides flexibility for different vector sizes.

test/functional/database-schema/vectors/sap/sap-vector.ts (4)

11-26: Good test structure with proper driver version checks.

The test setup correctly configures the SAP driver with vectorOutputType: "Array" and disables synchronization by default, which is appropriate for functional testing.


28-106: Comprehensive schema validation and data persistence testing.

The Array output type test thoroughly validates:

  • Schema synchronization and column metadata verification
  • Data persistence and hydration with realistic vector data
  • Proper handling of different vector configurations (fixed-length, nullable, variable-length)

The test data uses realistic floating-point vectors and properly validates the round-trip persistence.


150-196: Buffer output type test covers binary vector persistence well.

The Buffer output type test properly:

  • Uses the default vector output configuration (Buffer)
  • Tests serialization to fvecs format before persistence
  • Validates deserialization after hydration
  • Uses the same realistic test data for consistency

The test logic correctly handles the Buffer ↔ number[] conversion cycle.


122-148: Verify fvecs format implementation for correctness.

The fvecs serialization/deserialization functions appear to implement the correct binary format (length-prefixed float32 array with little-endian byte order). However, please verify this matches the exact SAP HANA Client fvecs specification.

What is the exact binary format specification for fvecs (float vector) format used by SAP HANA Client?

Copy link
Collaborator

@sgarner sgarner left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines -496 to -497
if (columnMetadata.type === Boolean) {
return value === true ? 1 : 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it intentional to lose the boolean conversions here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it was copy-pasted from a driver that doesn't support boolean (mssql?)

But @sap/hana-client is okay with receiving boolean values, no explicit conversion to 0 & 1 is needed.

@alumni alumni merged commit abf8863 into typeorm:master Jun 21, 2025
112 of 114 checks passed
Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Thanks @alumni you are doing great improvements 👏

@alumni alumni deleted the feature/sap-hana-real-vector branch June 22, 2025 11:18
ThbltLmr pushed a commit to ThbltLmr/typeorm that referenced this pull request Dec 2, 2025
…SAP HANA Cloud (typeorm#11526)

* feat(sap): add support for REAL_VECTOR data type

* feat(sap): add support for HALF_VECTOR data type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants