{"record":{"id":"34162a8121409afb","repo":"pathwaycom/pathway","slug":"schema-does-not-match-given-dataframe","errorCode":null,"errorMessage":"schema does not match given dataframe","messagePattern":"schema does not match given dataframe","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/debug/__init__.py","lineNumber":382,"sourceCode":"    _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})\n        ids_df.index = df.index\n    else:\n        ids_df = df[id_from].copy()\n\n    for column in api.PANDAS_PSEUDOCOLUMNS:\n        if column in df.columns:\n            ids_df[column] = df[column]\n\n    as_hashes = [fingerprint(x) for x in ids_df.to_dict(orient=\"records\")]\n    key = fingerprint((unsafe_trusted_ids, sorted(as_hashes)))","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/debug/__init__.py#L364-L400","documentation":"Output connectors such as the ClickHouse/Delta writers accept a string init_mode that is mapped to an engine enum (DEFAULT, CREATE_IF_NOT_EXISTS, REPLACE). init_mode_from_str raises ValueError for any string outside the supported set.","triggerScenarios":"Calling pw.io.clickhouse.write (or a similar writer) with init_mode set to a value other than \"default\", \"create_if_not_exists\", or \"replace\" — including case variants like \"REPLACE\" or newer ClickHouse modes like \"create\".","commonSituations":"User copies a mode name from ClickHouse SQL documentation (e.g. CREATE TABLE ... REPLACE TABLE) instead of the Pathway enum; or typos/case-mismatches the value; or passes a mode added in a newer Pathway version while running an older one.","solutions":["Use one of the exact supported strings: \"default\", \"create_if_not_exists\", or \"replace\" (lowercase).","Check the installed Pathway version's docstring for pw.io.clickhouse.write to see the accepted init_mode values.","Upgrade pathway if the mode you need is documented but missing in your version."],"exampleFix":"# before\npw.io.clickhouse.write(t, ..., init_mode=\"CREATE_IF_NOT_EXISTS\")\n\n# after\npw.io.clickhouse.write(t, ..., init_mode=\"create_if_not_exists\")","handlingStrategy":"validation","validationCode":"VALID_INIT_MODES = {\"default\", \"create_if_not_exists\", \"replace\"}\nif init_mode not in VALID_INIT_MODES:\n    raise ValueError(f\"init_mode must be one of {sorted(VALID_INIT_MODES)}\")\npw.io.clickhouse.write(t, ..., init_mode=init_mode)","typeGuard":"from typing import Literal\nInitMode = Literal[\"default\", \"create_if_not_exists\", \"replace\"]\n\ndef is_init_mode(s: str) -> TypeGuard[InitMode]:\n    return s in {\"default\", \"create_if_not_exists\", \"replace\"}","tryCatchPattern":null,"preventionTips":["Type the config field as a Literal of the three allowed values so mypy catches typos.","Don't copy init_mode strings from ClickHouse SQL docs; use the Pathway spelling."],"tags":["pathway","clickhouse","configuration","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}