{"record":{"id":"98ff8631c0d28ddc","repo":"pathwaycom/pathway","slug":"some-columns-have-types-incompatible-with-expected","errorCode":null,"errorMessage":"Some columns have types incompatible with expected types: {joined details}","messagePattern":"Some columns have types incompatible with expected types: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/stdlib/indexing/typecheck_utils.py","lineNumber":33,"sourceCode":"    failed = []\n    for name, (expr, types) in parameters:\n        expr_type = eval_type(expr)\n        if isinstance(types, tuple):\n            single_type = types[0]\n            valid = any(dt.dtype_issubclass(expr_type, dtype) for dtype in types)\n        else:\n            single_type = types\n            valid = dt.dtype_issubclass(eval_type(expr), single_type)\n        if not valid:\n            failed.append((name, (expr_type, single_type)))\n\n    if failed:\n        msg = \"Some columns have types incompatible with expected types: \" + \", \".join(\n            f\"{name} should be compatible with type {dtype!r} but is of type {expr_type!r}\"\n            for (name, (expr_type, dtype)) in failed\n        )\n\n        raise TypeError(msg)\n","sourceCodeStart":15,"sourceCodeEnd":34,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/stdlib/indexing/typecheck_utils.py#L15-L34","documentation":"Pathway's indexing helpers use check_default_bm25_column_types / typecheck_utils to verify that columns fed into an index (data column, metadata column, query column) have dtypes compatible with what the index backend expects (e.g. str for BM25 text, arrays for vectors). When one or more checked columns fail the dtype subtype test, a single TypeError is raised enumerating each failure as '<name> should be compatible with type X but is of type Y'.","triggerScenarios":"Passing a column whose dtype does not satisfy the required type to a stdlib index API — e.g. calling query_as_of_now on a BM25 index with an int-typed query column, or providing bytes/Optional[str] metadata where str is required; the checker compares dtypes via dt.dtype_issubclass(eval_type(expr), expected).","commonSituations":"Optional[str] columns (dtype Optional) that must be filtered or unwrapped before indexing; CSV-inferred columns parsed as int/float where the connector expects text; schema drift after an upstream join changes a column's type.","solutions":["Cast the column to the required type before indexing, e.g. pw.this.query.astype(str) or apply(pw.declare_type(str, str), pw.this.col).","Filter out nulls first if the column is Optional: t = t.filter(pw.this.col.is_not_none()).","Fix the schema at the input connector (dtype declarations in pw.Schema or format hints) so the column arrives with the right type."],"exampleFix":"# before\nres = index.query_as_of_now(query_table.q)  # q is int-typed\n\n# after\nquery_table = query_table.select(q=pw.this.q.astype(str))\nres = index.query_as_of_now(query_table.q)","handlingStrategy":"validation","validationCode":"from pathway import dt\n\ndef column_matches(table, name: str, expected) -> bool:\n    return dt.dtype_issubclass(table.schema[name].dtype, expected)","typeGuard":"from pathway import dt\n\ndef is_str_column(table, name: str) -> bool:\n    return dt.dtype_issubclass(table.schema[name].dtype, dt.str())","tryCatchPattern":"try:\n    res = index.query_as_of_now(q)\nexcept TypeError as e:\n    if \"types incompatible\" in str(e):\n        raise ValueError(f\"Index input column has wrong dtype: {e}\") from e\n    raise","preventionTips":["Declare dtypes explicitly in pw.Schema for columns feeding indices instead of relying on inference.","After joins/optional columns, filter is_not_none() or astype(str) before passing columns to index APIs."],"tags":["pathway","type-check","indexing","dtype"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}