pathwaycom/pathway · error · TypeError
Some columns have types incompatible with expected types: {j
Error message
Some columns have types incompatible with expected types: {joined details} What it means
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'.
Source
Thrown at python/pathway/stdlib/indexing/typecheck_utils.py:33
failed = []
for name, (expr, types) in parameters:
expr_type = eval_type(expr)
if isinstance(types, tuple):
single_type = types[0]
valid = any(dt.dtype_issubclass(expr_type, dtype) for dtype in types)
else:
single_type = types
valid = dt.dtype_issubclass(eval_type(expr), single_type)
if not valid:
failed.append((name, (expr_type, single_type)))
if failed:
msg = "Some columns have types incompatible with expected types: " + ", ".join(
f"{name} should be compatible with type {dtype!r} but is of type {expr_type!r}"
for (name, (expr_type, dtype)) in failed
)
raise TypeError(msg)
View on GitHub (pinned to fa2f74a464)
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.
Example fix
# before res = index.query_as_of_now(query_table.q) # q is int-typed # after query_table = query_table.select(q=pw.this.q.astype(str)) res = index.query_as_of_now(query_table.q)
Defensive patterns
Strategy: validation
Validate before calling
from pathway import dt
def column_matches(table, name: str, expected) -> bool:
return dt.dtype_issubclass(table.schema[name].dtype, expected) Type guard
from pathway import dt
def is_str_column(table, name: str) -> bool:
return dt.dtype_issubclass(table.schema[name].dtype, dt.str()) Try / catch
try:
res = index.query_as_of_now(q)
except TypeError as e:
if "types incompatible" in str(e):
raise ValueError(f"Index input column has wrong dtype: {e}") from e
raise Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Cannot flatten column of type {dtype}.
- Unsupported type {input_type}, use pw.DATE_TIME_UTC or pw.DA
- Unsupported type {input_type}, use pw.DURATION
- Unsupported type {input_type!r}.
- Failed to parse DType from dict: {data}
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/98ff8631c0d28ddc.
Report an issue: GitHub.