{"record":{"id":"c2230393aa522cc9","repo":"pathwaycom/pathway","slug":"parameters-schema-and-id-from-are-mutually-exc","errorCode":null,"errorMessage":"parameters `schema` and `id_from` are mutually exclusive","messagePattern":"parameters `schema` and `id_from` are mutually exclusive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/debug/__init__.py","lineNumber":372,"sourceCode":"\n\n@check_arg_types\n@trace_user_frame\ndef table_from_pandas(\n    df: pd.DataFrame,\n    id_from: list[str] | None = None,\n    unsafe_trusted_ids: bool = False,\n    schema: type[Schema] | None = None,\n    _stacklevel: int = 1,\n    _new_universe: bool = False,\n) -> Table:\n    \"\"\"A function for creating a table from a pandas DataFrame. If it contains a special\n    column ``__time__``, rows will be split into batches with timestamps from the column.\n    A special column ``__diff__`` can be used to set an event type - with ``1`` treated\n    as inserting the row and ``-1`` as removing it.\n    \"\"\"\n    if id_from is not None and schema is not None:\n        raise ValueError(\"parameters `schema` and `id_from` are mutually exclusive\")\n\n    ordinary_columns_names = [\n        column for column in df.columns if column not in api.PANDAS_PSEUDOCOLUMNS\n    ]\n    if schema is None:\n        schema = schema_from_pandas(\n            df, id_from=id_from, exclude_columns=api.PANDAS_PSEUDOCOLUMNS\n        )\n    elif set(ordinary_columns_names) != set(schema.column_names()):\n        raise ValueError(\"schema does not match given dataframe\")\n\n    _validate_dataframe(df, stacklevel=_stacklevel + 4)\n\n    if id_from is None and schema is not None:\n        id_from = schema.primary_key_columns()\n\n    if id_from is None:\n        ids_df = pd.DataFrame({\"id\": df.index})","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/debug/__init__.py#L354-L390","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Pass a column of the same table being written, e.g. time_column=table.time instead of other_table.time.","If the column genuinely lives on another table, join or select it into the target table first, then reference the target table's column."],"exampleFix":"# before\npw.io.postgres.write(orders, ..., time_column=events.time)\n\n# after\npw.io.postgres.write(orders, ..., time_column=orders.time)","handlingStrategy":"validation","validationCode":"def assert_same_table(table: pw.Table, *columns: pw.ColumnReference) -> None:\n    for c in columns:\n        if c is not None and c._table is not table:\n            raise ValueError(f\"{c} not from {table}\")\n\nassert_same_table(t, time_column)\npw.io.postgres.write(t, ..., time_column=time_column)","typeGuard":"def belongs_to(column: pw.ColumnReference, table: pw.Table) -> bool:\n    return column._table is table","tryCatchPattern":null,"preventionTips":["Always pass column references via table.column syntax at the call site, not variables captured earlier.","After with_columns/join refactorings, re-check every column argument passed to connectors."],"tags":["pathway","column-reference","validation","connector"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}