sqlalchemy / sqlalchemy/sqlalchemy

Add support for MariaDB Vector data type

Open
#12,628 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

datatypes mariadb oracle use case
Dominant language
Python
Stars
12.2k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the use case

MariaDB has introduced a new Vector data type in version 11.7. Details can be found here:
https://mariadb.org/projects/mariadb-vector/

The main issue I'm running into now is that reflection fails when reflecting on any table that has a vector column. The reflection fails to retrieve the columns as it sees the vector column and defaults it to NullType which eventually results in an exception.

Databases / Backends / Drivers targeted

mariadb
pymysql

Example Use

Creating a table with a vector column and index:

CREATE TABLE products (
    name varchar(128),
    description varchar(2000),
    embedding VECTOR(4) NOT NULL,  # Make sure the dimensions match your AI model's output
    VECTOR INDEX (embedding) M=6 DISTANCE=euclidean)
ENGINE=InnoDB;

The column should be queried using the built in vector search functions VEC_DISTANCE_EUCLIDEAN or VEC_DISTANCE_COSINE:

SELECT p.name, p.description
FROM products AS p
ORDER BY VEC_DISTANCE_EUCLIDEAN(p.embedding,
                      VEC_FromText('[0.3, 0,5, 0.1, 0.3]'))
LIMIT 10
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named in the issue. Start by tracing MariaDB/PyMySQL column reflection for a VECTOR column and consult the MariaDB 11.7 vector documentation. Done means reflection succeeds for tables containing VECTOR columns and the reported type is no longer NullType, with coverage for the example schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
mariadb, python
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.