cocoindex-io/cocoindex · error
VectorSchemaProvider only supported for ndarray. Got: {pytho
Error message
VectorSchemaProvider only supported for ndarray. Got: {python_type} What it means
The Doris target connector can only convert vector column values when the declared Python type maps to numpy ndarray with an explicit vector schema (size/dtype). If a VectorSchemaProvider is attached to a column whose Python type is anything else (list, sequence, etc.), _get_type_mapping rejects it because there is no reliable way to serialize it to Doris's ARRAY<FLOAT>.
Source
Thrown at python/cocoindex/connectors/doris/_target.py:313
if isinstance(annotation, DorisType):
return _TypeMapping(annotation.doris_type, annotation.encoder)
base_type = type_info.base_type
if base_type in _LEAF_TYPE_MAPPINGS:
return _LEAF_TYPE_MAPPINGS[base_type]
if base_type is np.ndarray:
if vector_schema is None:
raise ValueError("VectorSchemaProvider is required for NumPy ndarray type.")
if vector_schema.size <= 0:
raise ValueError(f"Invalid vector dimension: {vector_schema.size}")
return _TypeMapping(
"ARRAY<FLOAT>",
lambda v: v.tolist() if hasattr(v, "tolist") else list(v),
)
elif vector_schema is not None:
raise ValueError(
f"VectorSchemaProvider only supported for ndarray. Got: {python_type}"
)
if isinstance(
type_info.variant, (SequenceType, MappingType, RecordType, UnionType, AnyType)
):
return _JSON_MAPPING
return _JSON_MAPPING
# ============================================================
# Column / Table definitions
# ============================================================
class ColumnDef(NamedTuple):
type: str # Doris SQL typeView on GitHub (pinned to e84aa99b32)
Solutions
- Change the record field's Python type to numpy.ndarray (np.typing.NDArray[np.float32]) so the vector mapping path is taken
- Remove the VectorSchemaProvider override and let the column map as a generic ARRAY type
- Convert values to ndarray at write time before declaring rows
Example fix
// before
class Doc(res_schema.Record):
embedding: list[float] = res_schema.field(vector_schema=VectorSchemaProvider(size=384))
// after
import numpy as np
class Doc(res_schema.Record):
embedding: np.ndarray = res_schema.field(vector_schema=VectorSchemaProvider(size=384)) Defensive patterns
Strategy: validation
Validate before calling
import numpy as np
assert isinstance(doc.embedding, np.ndarray), f"embedding must be ndarray, got {type(doc.embedding)}" Type guard
def is_ndarray(v: object) -> bool:
return isinstance(v, np.ndarray) Prevention
- Type vector fields as np.ndarray in record definitions
- Keep VectorSchemaProvider overrides only on ndarray fields
- Add a unit test that builds the Doris table schema from your record type
When it happens
Trigger: Declaring a Doris table column with column_overrides containing a res_schema.VectorSchemaProvider for a field whose Python type is not an ndarray-backed vector type (e.g. list[float] or Any), then calling DorisTableSchema.from_class / _columns_from_record_type.
Common situations: Users define their record field as a plain Python list[float] but attach a VectorSchemaProvider expecting Doris VECTOR/ARRAY<FLOAT> mapping; or switch embedding pipelines to return lists instead of numpy arrays while keeping the vector schema override.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- VectorSchemaProvider is required for NumPy ndarray type.
- record_type must be a record type, got {type(record_type)}
- VectorSchemaProvider is only supported for NumPy ndarray typ
- VectorSchemaProvider is only supported for NumPy ndarray typ
- VectorSchemaProvider is only supported for NumPy ndarray typ
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/12990800d9c2417d.
Report an issue: GitHub.