pathwaycom/pathway · error · ValueError

parameters `schema` and `id_from` are mutually exclusive

Error message

parameters `schema` and `id_from` are mutually exclusive

What it means

Several Pathway output connectors take an optional ColumnReference (e.g. a time or key column) resolved via get_column_index; the helper verifies the referenced column belongs to the exact table being written and raises ValueError otherwise, since column indices are per-table.

Source

Thrown at python/pathway/debug/__init__.py:372


@check_arg_types
@trace_user_frame
def table_from_pandas(
    df: pd.DataFrame,
    id_from: list[str] | None = None,
    unsafe_trusted_ids: bool = False,
    schema: type[Schema] | None = None,
    _stacklevel: int = 1,
    _new_universe: bool = False,
) -> Table:
    """A function for creating a table from a pandas DataFrame. If it contains a special
    column ``__time__``, rows will be split into batches with timestamps from the column.
    A special column ``__diff__`` can be used to set an event type - with ``1`` treated
    as inserting the row and ``-1`` as removing it.
    """
    if id_from is not None and schema is not None:
        raise ValueError("parameters `schema` and `id_from` are mutually exclusive")

    ordinary_columns_names = [
        column for column in df.columns if column not in api.PANDAS_PSEUDOCOLUMNS
    ]
    if schema is None:
        schema = schema_from_pandas(
            df, id_from=id_from, exclude_columns=api.PANDAS_PSEUDOCOLUMNS
        )
    elif set(ordinary_columns_names) != set(schema.column_names()):
        raise ValueError("schema does not match given dataframe")

    _validate_dataframe(df, stacklevel=_stacklevel + 4)

    if id_from is None and schema is not None:
        id_from = schema.primary_key_columns()

    if id_from is None:
        ids_df = pd.DataFrame({"id": df.index})

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Pass a column of the same table being written, e.g. time_column=table.time instead of other_table.time.
  2. If the column genuinely lives on another table, join or select it into the target table first, then reference the target table's column.

Example fix

# before
pw.io.postgres.write(orders, ..., time_column=events.time)

# after
pw.io.postgres.write(orders, ..., time_column=orders.time)
Defensive patterns

Strategy: validation

Validate before calling

def assert_same_table(table: pw.Table, *columns: pw.ColumnReference) -> None:
    for c in columns:
        if c is not None and c._table is not table:
            raise ValueError(f"{c} not from {table}")

assert_same_table(t, time_column)
pw.io.postgres.write(t, ..., time_column=time_column)

Type guard

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

Prevention

When it happens

Trigger: Passing a column reference obtained from a different table than the one passed to the connector, e.g. pw.io.<connector>.write(table_a, ..., time_column=table_b.t).

Common situations: User has multiple tables in a pipeline (raw and transformed) and picks a column from the wrong variable; or refactors a pipeline and the column argument still points at the pre-transform table.

Related errors


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