pathwaycom/pathway · error · ValueError

primary_key and vector both reference column {pk_name!r}; th

Error message

primary_key and vector both reference column {pk_name!r}; they must be different columns.

What it means

Raised by pw.io.pinecone.write() when primary_key and vector resolve to the same column name. A Pinecone record id cannot also be its own embedding vector, so the connector rejects the duplicate reference up front rather than sending malformed upserts.

Source

Thrown at python/pathway/io/pinecone/__init__.py:356

    if primary_key is not None and primary_key._table is not table:
        raise ValueError(
            f"primary_key column {primary_key._name!r} does not belong to the "
            f"provided table. Pass a column reference from the same table, "
            f"e.g. primary_key=table.{primary_key._name}."
        )
    if vector._table is not table:
        raise ValueError(
            f"vector column {vector._name!r} does not belong to the provided "
            f"table. Pass a column reference from the same table, "
            f"e.g. vector=table.{vector._name}."
        )

    pk_name = primary_key._name if primary_key is not None else None
    vector_name = vector._name

    if pk_name == vector_name:
        raise ValueError(
            f"primary_key and vector both reference column {pk_name!r}; they must "
            "be different columns."
        )

    if metadata_columns is None:
        metadata_names = [
            col_name
            for col_name in table.column_names()
            if col_name not in (pk_name, vector_name)
        ]
    else:
        metadata_names = []
        for col in metadata_columns:
            if col._table is not table:
                raise ValueError(
                    f"metadata column {col._name!r} does not belong to the "
                    f"provided table. Pass column references from the same table, "
                    f"e.g. table.{col._name}."

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Choose distinct columns: primary_key=table.doc_id, vector=table.embedding.
  2. If the data really is one column, materialize a separate id column first (e.g. with table.with_columns() or an index) before writing.

Example fix

# before
pw.io.pinecone.write(table, index_name="docs", primary_key=table.v, vector=table.v, api_key=k)
# after
pw.io.pinecone.write(table, index_name="docs", primary_key=table.doc_id, vector=table.v, api_key=k)
Defensive patterns

Strategy: validation

Validate before calling

if primary_key is not None and primary_key._name == vector._name:
    raise ValueError("primary_key and vector must be different columns")

Prevention

When it happens

Trigger: Passing the same column reference for both arguments: primary_key=table.v, vector=table.v; or two same-named columns from the same table when primary_key defaults collide with the vector choice.

Common situations: Copy-pasting a write() call and forgetting to change the vector column; pipelines where the id column temporarily holds embeddings during migration.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/80bdaef8d3bdb141. Report an issue: GitHub.