{"record":{"id":"7f27e84486589e92","repo":"cocoindex-io/cocoindex","slug":"column-column-not-found-in-table-schema-list","errorCode":null,"errorMessage":"Column '{column}' not found in table schema: {list(self._table_schema.columns.keys())}","messagePattern":"Column '(.+?)' not found in table schema: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/lancedb/_target.py","lineNumber":1334,"sourceCode":"        Declare a vector index on a column of this LanceDB table.\n\n        Uses LanceDB's async ``create_index`` API with IVF-PQ or HNSW-PQ.\n\n        Args:\n            name: Logical index name (defaults to ``column``).\n            column: Column to index.\n            metric: Distance metric (\"cosine\", \"l2\", or \"dot\").\n            index_type: Index algorithm: \"ivf_pq\" (IVF-PQ) or \"hnsw_pq\" (HNSW-PQ).\n            num_partitions: (ivf_pq only) Number of IVF partitions.\n            num_sub_vectors: (ivf_pq / hnsw_pq) Number of PQ sub-vectors.\n            num_bits: (ivf_pq / hnsw_pq) Number of bits per PQ code.\n            m: (hnsw_pq only) Maximum number of HNSW edges per node.\n            ef_construction: (hnsw_pq only) Size of the HNSW candidate list during build.\n        \"\"\"\n        if name is None:\n            name = column\n        if column not in self._table_schema.columns:\n            raise ValueError(\n                f\"Column '{column}' not found in table schema: \"\n                f\"{list(self._table_schema.columns.keys())}\"\n            )\n        spec = _VectorIndexSpec(\n            column=column,\n            metric=metric,\n            index_type=index_type,\n            num_partitions=num_partitions,\n            num_sub_vectors=num_sub_vectors,\n            num_bits=num_bits,\n            m=m,\n            ef_construction=ef_construction,\n        )\n        att_provider = self._provider.attachment(\"vector_index\")\n        coco.declare_target_state(att_provider.target_state(name, spec))\n\n    def declare_fts_index(\n        self: \"TableTarget[RowT]\",","sourceCodeStart":1316,"sourceCodeEnd":1352,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/lancedb/_target.py#L1316-L1352","documentation":"declare_vector_index builds a vector index over an existing declared column. Before creating the index spec it checks the column exists in the target's table schema; if not, it raises ValueError listing the available columns. This prevents creating an index that LanceDB would reject.","triggerScenarios":"Calling table_target.declare_vector_index(column=..., metric=...) with a column name that is not in the declared table schema (typo, renamed field, or indexing a column declared later or in a different target).","commonSituations":"Typos in the column name; renaming an embedding column (e.g. 'vector' -> 'embedding') without updating the index declaration; declaring the index on the wrong table target; copying example code with different column names.","solutions":["Fix the column name to match one of the schema columns printed in the message","Declare the column in the table spec first, then declare the vector index on it","Verify you are calling declare_vector_index on the target whose schema actually contains that column"],"exampleFix":"// before\nawait target.declare_vector_index(column=\"embedding\", metric=\"cosine\")  # column is named 'vector'\n// after\nawait target.declare_vector_index(column=\"vector\", metric=\"cosine\")","handlingStrategy":"validation","validationCode":"available = target.table_schema.columns  # or the schema you declared\nassert \"embedding\" in available, f\"column missing; have {list(available)}\"\nawait target.declare_vector_index(column=\"embedding\", metric=\"cosine\")","typeGuard":"def column_exists(schema, column: str) -> bool:\n    return column in getattr(schema, \"columns\", {})","tryCatchPattern":"try:\n    target.declare_vector_index(column=name, metric=metric)\nexcept ValueError as e:\n    if \"not found in table schema\" in str(e):\n        raise KeyError(f\"{name!r} not declared; available: {list(schema.columns)}\") from e\n    raise","preventionTips":["Declare the index immediately after the column in the same schema block","Use constants/shared names for column names instead of string literals in multiple places","Copy column names from the error's available-columns list to spot typos","Check whether you're holding the right target object before declaring indexes"],"tags":["lancedb","vector-index","schema"],"backgroundTag":"resource-not-found","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"}