{"record":{"id":"1e7f5449baf20340","repo":"pathwaycom/pathway","slug":"primary-key-column-primary-key-name-r-does-not-1e7f54","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":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/pinecone/__init__.py","lineNumber":340,"sourceCode":"    ...     primary_key=table.doc_id,\n    ...     vector=table.embedding,\n    ...     metadata_columns=[table.title],\n    ...     api_key=\"YOUR_API_KEY\",\n    ... )\n    >>> pw.io.pinecone.write(   # doctest: +SKIP\n    ...     table,\n    ...     index_name=\"docs-sparse\",\n    ...     primary_key=table.doc_id,\n    ...     vector=table.bm25,\n    ...     metadata_columns=[table.title],\n    ...     api_key=\"YOUR_API_KEY\",\n    ... )\n    >>> pw.run(monitoring_level=pw.MonitoringLevel.NONE)  # doctest: +SKIP\n    \"\"\"\n    _check_entitlements(\"pinecone\")\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._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_name = primary_key._name if primary_key is not None else None\n    vector_name = vector._name\n\n    if pk_name == vector_name:\n        raise ValueError(\n            f\"primary_key and vector both reference column {pk_name!r}; they must \"\n            \"be different columns.\"","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/pinecone/__init__.py#L322-L358","documentation":"pw.io.pinecone.write requires the primary_key column reference to come from the exact table being written; a reference from any other table (or a column of a different pipeline stage) cannot be evaluated in this sink's context. The connector checks primary_key._table is not table at call time and raises this ValueError with a suggested corrected form.","triggerScenarios":"Passing primary_key=some_other_table.id or a column reference captured before a filter/join/with_columns chain produced a new table object, while the first positional argument is a different table object.","commonSituations":"Reusing a column reference variable from an earlier pipeline stage after the table was transformed (transformations return new Table objects); copy-pasting write() calls and mixing references between two tables; passing a source-table key alongside a joined/enriched table.","solutions":["Re-take the column reference from the exact table you pass as the first argument: primary_key=table.doc_id (same object).","Store the final table in one variable and reference all sink columns from it after all transformations.","Note that filter/rename/with_columns return new tables — always re-index column references from the latest table."],"exampleFix":"# before\nbase = pw.io.jsonlines.read(\"in.jsonl\", schema=InSchema)\nkey_ref = base.doc_id\nenriched = base.with_columns(score=pw.this.text.len())\npw.io.pinecone.write(enriched, \"idx\", primary_key=key_ref, vector=enriched.vec)\n\n# after\nenriched = base.with_columns(score=pw.this.text.len())\npw.io.pinecone.write(enriched, \"idx\", primary_key=enriched.doc_id, vector=enriched.vec)","handlingStrategy":"type-guard","validationCode":"def belongs_to(col_ref, table) -> bool:\n    return col_ref._table is table\n\nassert primary_key is None or belongs_to(primary_key, table), (\n    f\"primary_key must reference a column of the same table, got {primary_key._name!r}\"\n)\nassert belongs_to(vector, table), \"vector must reference a column of the same table\"","typeGuard":"def is_column_of(col_ref, table) -> bool:\n    \"\"\"True when col_ref belongs to exactly this Table instance.\"\"\"\n    return getattr(col_ref, \"_table\", None) is table","tryCatchPattern":"try:\n    pw.io.pinecone.write(enriched, \"idx\", primary_key=key_ref, vector=enriched.vec)\nexcept ValueError as e:\n    if \"does not belong to\" in str(e):\n        pw.io.pinecone.write(enriched, \"idx\", primary_key=enriched.doc_id, vector=enriched.vec)\n    else:\n        raise","preventionTips":["Always re-derive column references from the final table object after transformations.","Keep one variable per pipeline stage; never mix references across stages in sink calls.","Remember Pathway transformations (filter/with_columns/select) return new Table objects."],"tags":["pinecone","column-reference","table-identity","api-misuse","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}