{"record":{"id":"2c4f7278fcda247e","repo":"pathwaycom/pathway","slug":"column-of-type-dtypes-0-has-no-attribute-expre","errorCode":null,"errorMessage":"Column of type {dtypes[0]} has no attribute {expression._name}.","messagePattern":"Column of type (.+?) has no attribute (.+?)\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/graph_runner/expression_evaluator.py","lineNumber":782,"sourceCode":"\n    def eval_method_call(\n        self,\n        expression: expr.MethodCallExpression,\n        eval_state: RowwiseEvalState | None = None,\n    ):\n        dtypes = tuple([arg._dtype for arg in expression._args])\n        if (dtypes_and_handler := expression.get_function(dtypes)) is not None:\n            new_dtypes, _, handler = dtypes_and_handler\n\n            expressions = [\n                self.eval_expression(\n                    expr.CastExpression(dtype, arg),\n                    eval_state=eval_state,\n                )\n                for dtype, arg in zip(new_dtypes, expression._args)\n            ]\n            return handler(*expressions)\n        raise AttributeError(\n            f\"Column of type {dtypes[0]} has no attribute {expression._name}.\"\n        )\n\n    def eval_unwrap(\n        self,\n        expression: expr.UnwrapExpression,\n        eval_state: RowwiseEvalState | None = None,\n    ):\n        val = self.eval_expression(expression._expr, eval_state=eval_state)\n        return api.Expression.unwrap(val)\n\n    def eval_fill_error(\n        self,\n        expression: expr.FillErrorExpression,\n        eval_state: RowwiseEvalState | None = None,\n    ):\n        dtype = expression._dtype\n        ret = self.eval_expression(","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/graph_runner/expression_evaluator.py#L764-L800","documentation":"For a method-call expression (attribute access like .dt, .str, Json accessors, custom method mappings), the evaluator resolves a handler from the actual argument dtypes via expression.get_function(dtypes). If no method is registered for that dtype under the requested attribute name, it raises AttributeError mirroring python semantics: the column's type has no such attribute.","triggerScenarios":"Calling .dt methods on a str or int column (pw.this.col.dt.strftime(...) where col is not a datetime); .str.contains on an int column; Json accessors on a non-Json column; .dt on DateTimeNaive where only DateTimeUtc supports the method; typo in the method name.","commonSituations":"Schema drift: a column that used to parse as DateTimeUtc now arrives as str, breaking chained .dt calls; Optional-wrapped datetimes losing the namespace; copying example code against a differently-typed table.","solutions":["Fix the dtype first: parse strings with dt.strptime() into DATE_TIME_UTC/NAIVE before using .dt methods, or cast the column to the type the namespace requires","Unwrap Optional: apply .unwrap() (or fill errors) so a Optional[DateTimeUtc] becomes DateTimeUtc before attribute access","Check the message's dtype against the method's supported types in the docs; correct the method name if it is a typo"],"exampleFix":"// before\nformatted = pw.this.raw.dt.strftime('%Y-%m')  # raw is str\n// after\nparsed = pw.this.raw.dt.strptime('%Y-%m-%d %H:%M:%S%z')\nformatted = parsed.dt.strftime('%Y-%m')","handlingStrategy":"type-guard","validationCode":"def dtype_supports_namespace(dtype, namespace: str) -> bool:\n    ns_requires = {\"dt\": {\"DATE_TIME_NAIVE\", \"DATE_TIME_UTC\"}, \"str\": {\"STRING\"}}\n    return str(dtype) in ns_requires.get(namespace, set())","typeGuard":"from pathway.internals import dtype as dt\n\ndef is_datetime_dtype(dtype) -> bool:\n    return dtype in (dt.DATE_TIME_UTC, dt.DATE_TIME_NAIVE)","tryCatchPattern":"try:\n    run()\nexcept AttributeError as e:\n    if \"has no attribute\" in str(e):\n        # parse/cast the column to the dtype the method requires, then retry\n        ...","preventionTips":["strptime into a datetime dtype before using .dt methods","Unwrap Optional columns before attribute access","Add a schema assertion right after ingestion that key columns have the expected dtypes"],"tags":["pathway","attribute-access","dtype","namespace","expression"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}