pathwaycom/pathway · error · ValueError

text_column {text_column._name!r} does not belong to the pro

Error message

text_column {text_column._name!r} does not belong to the provided table. Pass a column reference from the same table, e.g. text_column=table.{text_column._name}.

What it means

pw.io.leann.write requires text_column to be a ColumnReference of the exact table passed as the first argument. Because ColumnReference objects are bound to a specific Table instance, a reference from a filtered/selected/derived table will not match, and Pathway raises this ValueError with a suggested correction.

Source

Thrown at python/pathway/io/leann/__init__.py:259

    ...     table,
    ...     index_path="./articles.leann",
    ...     text_column=table.body,
    ...     metadata_columns=[table.title, table.category],
    ...     backend_name="hnsw",
    ...     embedding_model="facebook/contriever",
    ... )

    Run the pipeline. In static mode the Pathway Live Data Framework processes the file once and
    writes the index; in streaming mode it keeps the index up to date as
    new articles arrive:

    >>> pw.run()  # doctest: +SKIP
    """
    _check_entitlements("leann")
    _check_leann_available()

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

    metadata_col_names: list[str] | None = None
    if metadata_columns is not None:
        for col in metadata_columns:
            if col._table is not table:
                raise ValueError(
                    f"metadata column {col._name!r} does not belong to the provided "
                    f"table. Pass column references from the same table, "
                    f"e.g. table.{col._name}."
                )
            _check_str_column(col, "metadata column")
        metadata_col_names = [col._name for col in metadata_columns]

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Pass the final table together with its own column: pw.io.leann.write(derived, path, text_column=derived.text)
  2. Re-derive the column from the table inside the call: text_column=table["text"]
  3. Keep one variable for the fully transformed table and use it exclusively for both the table and column arguments

Example fix

# before
clean = raw.select(text=raw.body)
pw.io.leann.write(raw, "idx", text_column=clean.text)

# after
clean = raw.select(text=raw.body)
pw.io.leann.write(clean, "idx", text_column=clean.text)
Defensive patterns

Strategy: validation

Validate before calling

assert text_column._table is table, (
    f"text_column {text_column._name!r} is from a different table; "
    f"use table.{text_column._name}"
)

Type guard

def column_from_table(table: pw.Table, col: pw.ColumnReference) -> bool:
    return col._table is table

Try / catch

try:
    pw.io.leann.write(table, "idx", table.text)
except ValueError as e:
    if "does not belong to the provided table" in str(e):
        text_column = table[text_column._name]  # rebind by name to the right table
    else:
        raise

Prevention

When it happens

Trigger: pw.io.leann.write(base_table, path, text_column=derived.text) where derived = base_table.filter(...).select(...) — any transform produces a new table whose column references fail the identity check.

Common situations: Keeping a reference to the pre-transform table for the write call while passing columns captured after transforms; helper functions that receive both a table and columns from different pipelines.

Related errors


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