{"record":{"id":"734abc48a494c9d6","repo":"pathwaycom/pathway","slug":"output-schema-validation-error-received-output-a","errorCode":null,"errorMessage":"output schema validation error, received {output.as_typehints()} vs expected {cls.output_schema.typehints()}","messagePattern":"output schema validation error, received (.+?) vs expected (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/row_transformer.py","lineNumber":173,"sourceCode":"        \"\"\"Pseudo-random hash of its argument. Produces pointer types. Applied value-wise.\"\"\"\n        return ref_scalar(*args, optional=optional)\n\n    def __init_subclass__(\n        cls,\n        input=Any,\n        output=Any,\n    ):\n        cls._attributes = {\n            attr.name: attr for attr in attrs_of_type(cls, AbstractAttribute)\n        }\n        cls.input_schema = input\n        cls.output_schema = schema_from_types(\n            **{attr.output_name: attr.dtype for attr in cls._output_attributes.values()}\n        )\n        if output is not Any and not schema.is_subschema(cls.output_schema, output):\n            print(output)\n            print(cls.output_schema)\n            raise RuntimeError(\n                f\"output schema validation error, received {output.as_typehints()} vs expected {cls.output_schema.typehints()}\"  # noqa\n            )\n        for attr in cls._attributes.values():\n            attr.class_arg = cls\n\n\nclass AbstractAttribute(ABC):\n    is_method = False\n    is_output = False\n    _dtype: dt.DType | None = None\n    class_arg: ClassArgMeta  # lateinit by parent ClassArg\n\n    def __init__(self, **params) -> None:\n        super().__init__()\n        self.params = params\n        self.name = self.params.get(\"name\", None)\n        if \"dtype\" in self.params:\n            self._dtype = dt.wrap(self.params[\"dtype\"])","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/row_transformer.py#L155-L191","documentation":"When a @pw.row_transformer class declares an explicit output= schema, Pathway validates that the schema generated from the transformer's output attributes is a subschema of that declared output. If an output attribute's dtype or name does not fit the declared output schema, this RuntimeError is raised (note: received/expected wording — the transformer's attributes must be assignable to `output`).","triggerScenarios":"Declaring @pw.row_transformer(input=InputSchema, output=OutputSchema) where an output attribute's dtype (e.g. int attribute vs float field in OutputSchema, or a missing/extra column) makes schema.is_subschema(cls.output_schema, output) false.","commonSituations":"Editing the transformer's output attributes without updating the declared output schema (or vice versa); version upgrades where attribute dtype inference changed (e.g. int vs float).","solutions":["Align the declared output schema with the transformer's output attributes: same column names, and attribute dtypes must be subtypes of the declared field types.","Reorder/fix type annotations on output attributes in the ClassArg so each matches the corresponding field of output=.","As a last resort omit output= and let the schema be derived from the attributes (only if downstream does not require the exact type)."],"exampleFix":"# before\n@pw.row_transformer(input=In, output=Out)  # Out.value: float\nclass T:\n    class output(pw.ClassArg):\n        value: int = pw.input_method()  # mismatch\n\n# after\n@pw.row_transformer(input=In, output=Out2)  # Out2.value: int\nclass T:\n    class output(pw.ClassArg):\n        value: int = pw.input_method()","handlingStrategy":"validation","validationCode":"import pathway as pw\n\ndef output_matches(derived: type[pw.Schema], declared: type[pw.Schema]) -> bool:\n    return pw.Schema.is_subschema(derived, declared) if hasattr(pw.Schema, 'is_subschema') else declared.is_subschema_of(derived) if False else __import__('pathway.internals.schema', fromlist=['schema']).schema.is_subschema(derived, declared)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unit-test each row transformer against its declared output schema right after defining it.","Regenerate the declared output schema from the transformer attributes when you change either side."],"tags":["pathway","row-transformer","schema-mismatch","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}