{"record":{"id":"90f844549d276a7c","repo":"pathwaycom/pathway","slug":"primary-key-column-primary-key-name-r-does-not-90f844","errorCode":null,"errorMessage":"primary_key column {primary_key._name!r} does not belong to the provided table. Pass a column reference from the same table, e.g. primary_key=table.{primary_key._name}.","messagePattern":"primary_key column (.+?) does not belong to the provided table\\. Pass a column reference from the same table, e\\.g\\. primary_key=table\\.(.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/weaviate/__init__.py","lineNumber":116,"sourceCode":"    ...     DocSchema,\n    ...     [(1, [0.1, 0.2, 0.3, 0.4]), (2, [0.5, 0.6, 0.7, 0.8])],\n    ... )\n\n    Attach the Weaviate output connector, mapping the primary key and the vector\n    column:\n\n    >>> pw.io.weaviate.write(  # doctest: +SKIP\n    ...     table,\n    ...     collection_name=\"Docs\",\n    ...     primary_key=table.doc_id,\n    ...     vector=table.embedding,\n    ... )\n    >>> pw.run(monitoring_level=pw.MonitoringLevel.NONE)  # doctest: +SKIP\n    \"\"\"\n    _check_entitlements(\"weaviate\")\n\n    if primary_key is not None and primary_key._table is not table:\n        raise ValueError(\n            f\"primary_key column {primary_key._name!r} does not belong to the \"\n            f\"provided table. Pass a column reference from the same table, \"\n            f\"e.g. primary_key=table.{primary_key._name}.\"\n        )\n    if vector is not None and vector._table is not table:\n        raise ValueError(\n            f\"vector column {vector._name!r} does not belong to the provided \"\n            f\"table. Pass a column reference from the same table, \"\n            f\"e.g. vector=table.{vector._name}.\"\n        )\n\n    pk = primary_key._name if primary_key is not None else None\n    vector_field = vector._name if vector is not None else None\n\n    # Weaviate reserves \"id\" and \"vector\" as object-level keys and rejects them as\n    # property names. The primary key (encoded in the UUID) and the vector column\n    # are never sent as properties, so they may freely use these names; any other\n    # column that does collides and is reported up front.","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/weaviate/__init__.py#L98-L134","documentation":"The Weaviate output connector requires that the primary_key column reference belongs to the same pw.Table instance passed as `table`; the key is encoded into Weaviate's deterministic object UUID, so a column from a different table would silently index the wrong data. write() compares primary_key._table to table and raises this ValueError with a suggested corrected expression when they differ.","triggerScenarios":"Calling pw.io.weaviate.write(table_a, ..., primary_key=table_b.doc_id) where table_b is any table other than table_a — e.g. a filtered, joined, or otherwise derived table object.","commonSituations":"Passing a column captured before a table transformation (t_filtered = t.filter(...) creates a new object); reusing a variable from an earlier pipeline step; passing schema.col class-attribute style references from a different table.","solutions":["Pass the column reference from the very table object you pass as `table`: primary_key=table.doc_id as the message suggests.","Re-derive the key column on the transformed table before writing (e.g. keep the key through filters/joins so table.doc_id exists)."],"exampleFix":"# before\nt_full = pw.io.csv.read(...)\nt = t_full.filter(pw.this.visible)\npw.io.weaviate.write(t, collection_name=\"Docs\", primary_key=t_full.doc_id)\n\n# after\npw.io.weaviate.write(t, collection_name=\"Docs\", primary_key=t.doc_id)","handlingStrategy":"validation","validationCode":"def check_column_belongs(table, col, arg=\"primary_key\"):\n    if col is not None and col._table is not table:\n        raise ValueError(f\"{arg} column {col.name!r} is not from the given table\")\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always reference columns from the exact object you pass as `table`; re-derive references after every filter/join/select since they return new objects.","Write connector calls immediately after the final transformation, keeping only one table variable in scope."],"tags":["pathway","weaviate","vector-store","column-reference"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}