{"record":{"id":"ef5ac4fc2b7006c8","repo":"pathwaycom/pathway","slug":"schema-with-types-argument-name-has-to-be-an-exi","errorCode":null,"errorMessage":"Schema.with_types() argument name has to be an existing column name, received f{name}.","messagePattern":"Schema\\.with_types\\(\\) argument name has to be an existing column name, received f(.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/schema.py","lineNumber":392,"sourceCode":"        return pkey_fields if pkey_fields else None\n\n    def default_values(self) -> dict[str, Any]:\n        return {\n            name: column.default_value\n            for name, column in self.__columns__.items()\n            if column.has_default_value()\n        }\n\n    def keys(self) -> KeysView[str]:\n        return self.__columns__.keys()\n\n    def with_types(self, **kwargs) -> type[Schema]:\n        columns: dict[str, ColumnDefinition] = {\n            col.name: col.to_definition() for col in self.__columns__.values()\n        }\n        for name, dtype in kwargs.items():\n            if name not in columns:\n                raise ValueError(\n                    f\"Schema.with_types() argument name has to be an existing column name, received f{name}.\"\n                )\n            columns[name] = dataclasses.replace(columns[name], dtype=dt.wrap(dtype))\n\n        return schema_builder(columns=columns, id_dtype=self.id.dtype)\n\n    def without(self, *args: str | expr.ColumnReference) -> type[Schema]:\n        columns: dict[str, ColumnDefinition] = {\n            col.name: col.to_definition() for col in self.__columns__.values()\n        }\n        for arg in args:\n            if isinstance(arg, str):\n                name = arg\n            else:\n                name = arg._name\n            try:\n                columns.pop(name)\n            except KeyError:","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/schema.py#L374-L410","documentation":"Schema.with_types(**kwargs) rewrites the dtypes of existing columns. Every keyword name must match a column of the schema; an unknown name cannot be remapped, so schema.py raises this ValueError (the message text contains a formatting bug — 'received f{name}' prints a literal 'f' — but the offending name is still shown).","triggerScenarios":"MySchema.with_types(price=float) when MySchema has no 'price' column (e.g. it is named 'cost' or 'amount'); also typos or renamed columns after refactors.","commonSituations":"Aligning CSV/json input schemas with connector expectations; renaming columns in a query but forgetting to update with_types calls.","solutions":["Check the schema's column names first (list(MySchema.keys()) or MySchema.column_names()) and use the exact name.","If you need to add a column, use schema composition (SchemaA | SchemaB) or define a new schema instead of with_types.","If the name should exist, fix the upstream rename so it does."],"exampleFix":"# before\nS2 = MySchema.with_types(price=float)  # column is 'cost'\n\n# after\nS2 = MySchema.with_types(cost=float)","handlingStrategy":"validation","validationCode":"import pathway as pw\n\ndef with_types_args_valid(schema_cls, kwargs: dict) -> bool:\n    return set(kwargs.keys()) <= set(schema_cls.keys())","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive with_types arguments from schema_cls.column_names() instead of typing names by hand.","Add a schema unit test asserting column names after every upstream rename."],"tags":["pathway","schema","api-misuse","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}