{"record":{"id":"f3e786dba34dfef8","repo":"cocoindex-io/cocoindex","slug":"auxiliary-columns-not-in-schema-invalid-aux","errorCode":null,"errorMessage":"Auxiliary columns not in schema: {invalid_aux}","messagePattern":"Auxiliary columns not in schema: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/sqlite/_target.py","lineNumber":1145,"sourceCode":"    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(\n            f\"vec0 virtual tables require INTEGER primary key, \"\n            f\"got {pk_col_type} for column '{pk_col_name}'\"\n        )\n\n\ndef table_target(\n    db: ContextKey[ManagedConnection],\n    table_name: str,\n    table_schema: TableSchema[RowT],","sourceCodeStart":1127,"sourceCodeEnd":1163,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/sqlite/_target.py#L1127-L1163","documentation":"The vec0 virtual table declares auxiliary columns, but those names are not present in the declared table schema. CocoIndex validates vec0 configuration at table_target() time so auxiliary column mismatches fail early rather than when SQLite creates the virtual table.","triggerScenarios":"Calling table_target() for a vec0 table where VirtualTableDef.auxiliary_columns includes a column name absent from table_schema.columns (typo, renamed/removed column, stale definition).","commonSituations":"Adding an auxiliary column to the vec0 definition but not to the row schema; renaming a schema column without updating auxiliary_columns; copy-pasted table definitions retaining columns from another table.","solutions":["Add the missing auxiliary column(s) to the table schema.","Correct auxiliary_columns entries to match actual schema column names.","Drop auxiliary_columns entries that are no longer needed."],"exampleFix":"// before\nvirtual_table_def = VirtualTableDef(auxiliary_columns=[\"source_text\"])\nschema = table_schema(columns=[\"id\", \"embedding\"])\n// after\nschema = table_schema(columns=[\"id\", \"embedding\", \"source_text\"])","handlingStrategy":"validation","validationCode":"invalid = set(auxiliary_columns) - set(schema.columns)\nif invalid:\n    raise ValueError(f\"auxiliary columns missing from schema: {invalid}\")","typeGuard":"def valid_aux_columns(schema, cols) -> bool:\n    return all(c in schema.columns for c in cols)","tryCatchPattern":"try:\n    target = table_target(schema, virtual_table_def)\nexcept ValueError as e:\n    if \"Auxiliary columns not in schema\" in str(e):\n        # align auxiliary_columns with schema.columns\n        ...","preventionTips":["Keep auxiliary_columns in the same config object as the column list so they change together.","Validate schema-vs-vec0 definitions in tests.","Avoid copy-pasting vec0 definitions between tables."],"tags":["sqlite","schema-validation","vec0","config"],"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"}