Skip to content

Conversation

dhairyadev26
Copy link

Description

This PR implements two new vector functions to maintain compatibility with Turso:

  1. vector_concat(X, Y) - Concatenates two vectors of the same type
  2. vector_slice(X, start_idx, end_idx) - Extracts a subvector from start_idx (inclusive) to end_idx (exclusive)

These functions were already available in Turso but were missing in libSQL, as noted in issue #2136.

Implementation Details

  • Added vector_func_impl.c with implementations of both functions
  • Included this file in libsql-sqlite3/src/vector.c
  • Created comprehensive tests in test_vector_functions.sql
  • Added documentation in README-vector-functions.md

Supported Vector Types

Both functions support all vector types except:

  • FLOAT1BIT for vector_slice (bit-by-bit extraction is more complex)

Testing

The implementation has been tested with the provided SQL test file that covers:

  • Basic functionality for both functions
  • Different vector types (FLOAT32, FLOAT64)
  • Edge cases (out of bounds indices, negative indices, etc.)

Fixes #2136

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.

Add vector_concat() and vector_slice() functions
1 participant