{"record":{"id":"dd5d7bae3ed5c3fa","repo":"cocoindex-io/cocoindex","slug":"vec0-virtual-tables-require-at-least-one-float-n","errorCode":null,"errorMessage":"vec0 virtual tables require at least one float[N] vector column","messagePattern":"vec0 virtual tables require at least one float\\[N\\] vector column","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/sqlite/_target.py","lineNumber":1136,"sourceCode":"        return self._provider.memo_key\n\n\ndef _validate_vec0_config(\n    table_schema: TableSchema[Any],\n    virtual_table_def: Vec0TableDef,\n    managed_conn: ManagedConnection,\n) -> None:\n    \"\"\"Validate vec0 virtual table configuration.\"\"\"\n    if _VEC_EXTENSION not in managed_conn.loaded_extensions:\n        raise RuntimeError(\n            \"sqlite-vec extension must be loaded for vec0 virtual tables. \"\n            \"Use connect(..., load_vec=True)\"\n        )\n    has_vector_col = any(\n        col_def.type.startswith(\"float[\") for col_def in table_schema.columns.values()\n    )\n    if not has_vector_col:\n        raise ValueError(\n            \"vec0 virtual tables require at least one float[N] vector column\"\n        )\n    all_cols = set(table_schema.columns.keys())\n    invalid_partition = set(virtual_table_def.partition_key_columns) - all_cols\n    if invalid_partition:\n        raise ValueError(f\"Partition key columns not in schema: {invalid_partition}\")\n    invalid_aux = set(virtual_table_def.auxiliary_columns) - all_cols\n    if invalid_aux:\n        raise ValueError(f\"Auxiliary columns not in schema: {invalid_aux}\")\n    if len(table_schema.primary_key) != 1:\n        raise ValueError(\n            f\"vec0 virtual tables require exactly one primary key column, \"\n            f\"got {len(table_schema.primary_key)}: {table_schema.primary_key}\"\n        )\n    pk_col_name = table_schema.primary_key[0]\n    pk_col_type = table_schema.columns[pk_col_name].type\n    if pk_col_type != \"INTEGER\":\n        raise ValueError(","sourceCodeStart":1118,"sourceCodeEnd":1154,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/sqlite/_target.py#L1118-L1154","documentation":"A `vec0` virtual table must contain at least one `float[N]` vector column — that is the entire point of the vec0 module. `_validate_vec0_config` scans the table schema columns and raises `ValueError` when none of the column types start with `float[`, i.e. a vec0 table was declared with only scalar columns.","triggerScenarios":"Constructing a `Vec0TableDef` for a table schema whose columns are all scalar (str/int/etc.); a `column_overrides` mapping that accidentally replaced the vector column with a plain type; forgetting to include the embedding field in the record type.","commonSituations":"Refactoring a record type and dropping the embeddings field while keeping `Vec0TableDef`; overriding the vector column type via `column_overrides` to a scalar SqliteType; copying vec0 setup without actually adding an embedding column.","solutions":["Add a float[N] vector column to the schema (e.g. via `VectorSchemaProvider` in `column_overrides` or a vector-typed field in the record)","Remove `Vec0TableDef` and use a regular table definition if no vector column is needed","Check that `column_overrides` is not overriding the embedding column to a scalar type"],"exampleFix":"// before\ncolumn_overrides={\"embedding\": sqlite.SqliteType.TEXT}\n// after\ncolumn_overrides={\"embedding\": sqlite.VectorSchemaProvider(dim=384)}","handlingStrategy":"validation","validationCode":"has_vec = any(str(c.type).startswith(\"float[\") for c in schema.columns.values())\nassert has_vec, \"vec0 table needs at least one float[N] vector column\"","typeGuard":"def has_vector_column(columns: dict) -> bool:\n    return any(str(c.type).startswith(\"float[\") for c in columns.values())","tryCatchPattern":"try:\n    target = sqlite.table_target(..., virtual_table_def=Vec0TableDef(...))\nexcept ValueError as e:\n    if \"require at least one float[N]\" in e.args[0]:\n        add_embedding_column_to_schema()\n    else:\n        raise","preventionTips":["Ensure the record type includes an embeddings field with a vector type","Do not override the vector column to a scalar SqliteType in column_overrides","Use a plain table (not Vec0TableDef) when no vector column is needed"],"tags":["sqlite","vec0","vector","schema-validation"],"backgroundTag":"schema-validation-failed","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"}