Skip to main content

Reflection

get_table_names, get_columns, get_pk_constraint, and get_indexes all read Milvus's own schema API (list_collections, describe_collection, list_indexes, describe_index) directly — not a SELECT-based probe through connection.execute(). Milvus has a real schema endpoint; there is no SQL text to route reflection through the way a SELECT * FROM table LIMIT 1 probe would for a database that doesn't expose one. get_foreign_keys always returns [] without calling the API at all, since Milvus has no foreign-key concept.

from sqlalchemy import inspect

insp = inspect(engine)
insp.get_table_names()
# ['items']

insp.get_columns("items")
# [{'name': 'id', 'type': BigInteger(), 'nullable': False, ...},
# {'name': 'category', 'type': String(length=64), 'nullable': True, ...},
# {'name': 'embedding', 'type': VECTOR(dim=768), 'nullable': False, ...}]

insp.get_pk_constraint("items")
# {'constrained_columns': ['id'], 'name': None}

insp.get_indexes("items")
# [{'name': 'embedding', 'column_names': ['embedding'], 'unique': False, ...}]

Milvus genuinely has no foreign keys, which is a fact about the database, not a missing feature in this dialect.

Type mapping

Only what phase-1 DDL actually emits is mapped; anything else reflects as NullType rather than guessing at a Python-side representation for a Milvus field type this dialect has never had reason to produce.

Milvus typeSQLAlchemy type
INT8/INT16SmallInteger
INT32Integer
INT64BigInteger
FLOAT/DOUBLEFloat/Double
BOOLBoolean
JSONJSON
VARCHARString(length=...)
FLOAT_VECTORVECTOR(dim=...)
SPARSE_FLOAT_VECTORSPARSEVEC()
TEXT, ARRAY and the new v1.0.0 vector types aren't in this map yet

Reflection's type map (milvusql_sqlalchemy.reflection._TYPE_MAP) hasn't been extended for the column types v1.0.0 added at the DBAPI/MilvusQL level: a TEXT column reflects as a plain String(length=65535) — indistinguishable from an ordinary VARCHAR(65535), since the map only looks at the Milvus field's VARCHAR type and ignores its enable_analyzer/enable_match flags. An ARRAY<T>(n) column, and BINARYVEC/FLOAT16VEC/BFLOAT16VEC/INT8VEC columns, all fall through to NullType() — there's no ARRAY/dimensioned-vector TypeEngine in Types for them to reflect onto. Confirmed directly against the reflection source; not yet fixed.