pathwaycom/pathway · error · ValueError
`{column_name}` should be a column definition, found {type(c
Error message
`{column_name}` should be a column definition, found {type(column)} What it means
When building a schema, each annotated column may only be assigned a column_definition(...) object. After dt.wrap of the annotation, the code pops the class-level field value and checks isinstance(column, ColumnDefinition); assigning anything else (a plain type, a tuple, a ColumnSchema, a default value directly) raises this ValueError.
Source
Thrown at python/pathway/internals/schema.py:208
# Update locals to handle recursive Schema definitions
localns[schema.__name__] = schema
annotations = get_type_hints(schema, localns=localns)
fields = _cls_fields(schema)
for base in bases:
if not isinstance(base, SchemaMetaclass):
continue
for column_name, column_schema in base.__columns__.items():
if column_name not in fields:
fields[column_name] = column_schema.to_definition()
columns = {}
for column_name, annotation in annotations.items():
col_dtype = dt.wrap(annotation)
column = fields.pop(column_name, column_definition(dtype=col_dtype))
if not isinstance(column, ColumnDefinition):
raise ValueError(
f"`{column_name}` should be a column definition, found {type(column)}"
)
dtype = column.dtype
if dtype is None:
dtype = col_dtype
if col_dtype != dtype:
raise TypeError(
f"type annotation of column `{column_name}` does not match column definition"
)
column_name = column.name or column_name
def _get_column_property(property_name: str, default: Any) -> Any:
match (
getattr(column, property_name),
getattr(schema_properties, property_name),View on GitHub (pinned to fa2f74a464)
Solutions
- Wrap any per-column option in column_definition: age: int = pw.column_definition(default_value=42).
- Do not assign raw types or values to annotated attributes; an annotation alone (age: int) is sufficient when no options are needed.
- When deriving schemas programmatically, convert ColumnSchema back with .to_definition() before passing into schema_builder.
Example fix
# before
class MySchema(pw.Schema):
age: int = 42
# after
class MySchema(pw.Schema):
age: int = pw.column_definition(default_value=42) Defensive patterns
Strategy: type-guard
Validate before calling
from pathway.internals.schema import column_definition, ColumnDefinition
def is_valid_column_value(v) -> bool:
return v is None or isinstance(v, ColumnDefinition) Type guard
from pathway.internals.schema import ColumnDefinition
from typing import TypeGuard
def is_column_definition(v) -> TypeGuard[ColumnDefinition]:
return isinstance(v, ColumnDefinition) Prevention
- Only ever assign column_definition(...) (or nothing) to annotated schema attributes.
- Use default_value= inside column_definition for defaults, never a bare value.
When it happens
Trigger: Writing class MySchema(pw.Schema): age: int = 42 or age: int = int (instead of column_definition(dtype=int, default_value=42)); also assigning a ColumnSchema object copied from another schema's columns() mapping.
Common situations: Trying to declare default values directly (pw.Schema requires column_definition(default_value=...)); migrating old ColumnSchema-based code; assigning dataclass-like sentinel values.
Related errors
- definitions of columns {names} lack type annotation
- type annotation of column `{column_name}` does not match col
- Failed to detect the region of S3 bucket {bucket!r} (HTTP st
- SchemaRegistryHeader.value must be a str, got {type(self.val
- argument {name} has incorrect schema
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/8d777362ad79f221.
Report an issue: GitHub.