{"record":{"id":"12990800d9c2417d","repo":"cocoindex-io/cocoindex","slug":"vectorschemaprovider-only-supported-for-ndarray-g","errorCode":null,"errorMessage":"VectorSchemaProvider only supported for ndarray. Got: {python_type}","messagePattern":"VectorSchemaProvider only supported for ndarray\\. Got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/doris/_target.py","lineNumber":313,"sourceCode":"        if isinstance(annotation, DorisType):\n            return _TypeMapping(annotation.doris_type, annotation.encoder)\n\n    base_type = type_info.base_type\n\n    if base_type in _LEAF_TYPE_MAPPINGS:\n        return _LEAF_TYPE_MAPPINGS[base_type]\n\n    if base_type is np.ndarray:\n        if vector_schema is None:\n            raise ValueError(\"VectorSchemaProvider is required for NumPy ndarray type.\")\n        if vector_schema.size <= 0:\n            raise ValueError(f\"Invalid vector dimension: {vector_schema.size}\")\n        return _TypeMapping(\n            \"ARRAY<FLOAT>\",\n            lambda v: v.tolist() if hasattr(v, \"tolist\") else list(v),\n        )\n    elif vector_schema is not None:\n        raise ValueError(\n            f\"VectorSchemaProvider only supported for ndarray. Got: {python_type}\"\n        )\n\n    if isinstance(\n        type_info.variant, (SequenceType, MappingType, RecordType, UnionType, AnyType)\n    ):\n        return _JSON_MAPPING\n\n    return _JSON_MAPPING\n\n\n# ============================================================\n# Column / Table definitions\n# ============================================================\n\n\nclass ColumnDef(NamedTuple):\n    type: str  # Doris SQL type","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/doris/_target.py#L295-L331","documentation":"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>.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nclass Doc(res_schema.Record):\n    embedding: list[float] = res_schema.field(vector_schema=VectorSchemaProvider(size=384))\n// after\nimport numpy as np\nclass Doc(res_schema.Record):\n    embedding: np.ndarray = res_schema.field(vector_schema=VectorSchemaProvider(size=384))","handlingStrategy":"validation","validationCode":"import numpy as np\nassert isinstance(doc.embedding, np.ndarray), f\"embedding must be ndarray, got {type(doc.embedding)}\"","typeGuard":"def is_ndarray(v: object) -> bool:\n    return isinstance(v, np.ndarray)","tryCatchPattern":null,"preventionTips":["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"],"tags":["doris","vector","type-mismatch","schema"],"backgroundTag":"type-mismatch","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}