pathwaycom/pathway · error · TypeError
Schemas should not be called. Use `table.schema` not `table.
Error message
Schemas should not be called. Use `table.schema` not `table.schema()`.
What it means
pw.Schema metaclass defines __call__ to always raise, because a Schema is a class (type definition), not an instance you construct or call. This guard catches the common mistake of treating table.schema like a method — the schema is a plain attribute in Pathway, unlike older APIs or pandas-style accessors.
Source
Thrown at python/pathway/internals/schema.py:318
self.__columns__ = _create_column_definitions(self, bases, schema_properties)
pk_dtypes = [col.dtype for col in self.__columns__.values() if col.primary_key]
if len(pk_dtypes) > 0:
derived_type = dt.Pointer(*pk_dtypes)
assert id_dtype in [derived_type, dt.ANY_POINTER]
id_dtype = derived_type
self.__universe_properties__ = _universe_properties(
list(self.__columns__.values()),
schema_properties,
dtype=id_dtype,
append_only=id_append_only,
)
self.__dtypes__ = {
name: column.dtype for name, column in self.__columns__.items()
}
self.__types__ = {k: v.typehint for k, v in self.__dtypes__.items()}
def __call__(self) -> NoReturn:
raise TypeError(
"Schemas should not be called. Use `table.schema` not `table.schema()."
)
def __or__(self, other: type[Schema]) -> type[Schema]: # type: ignore
return schema_add(self, other) # type: ignore
def columns(self) -> Mapping[str, ColumnSchema]:
return MappingProxyType(self.__columns__)
def column_names(self) -> list[str]:
return list(self.keys())
def columns_to_json_serializable_dict(self) -> dict:
columns = {}
for column_name, column_schema in self.columns().items():
columns[column_name] = column_schema.to_json_serializable_dict()
return columns
View on GitHub (pinned to fa2f74a464)
Solutions
- Use table.schema without parentheses: table.schema.columns(), table.schema.typehints(), etc.
- To create a typed empty table use pw.Table.empty(schema=MySchema) (or pw.debug.table_from_markdown for tests), not MySchema().
Example fix
# before cols = table.schema().columns() # after cols = table.schema.columns()
Defensive patterns
Strategy: type-guard
Validate before calling
import pathway as pw
def schema_usage_ok(table: pw.Table) -> None:
assert not callable(table.schema), "use table.schema (no parentheses)" Prevention
- Remember: table.schema is an attribute in current Pathway; never call it.
- Grep your codebase for 'schema()' when migrating from older Pathway versions.
When it happens
Trigger: Calling table.schema() (with parentheses) instead of using table.schema; also attempting to 'instantiate' a schema class like MySchema() to build an empty table.
Common situations: Migrating from Pathway versions or tutorials where schema() was callable; muscle memory from accessor methods; using table.schema().columns instead of table.schema.columns.
Related errors
- `{self.name}` has no attribute `{name}`
- Schema.with_types() argument name has to be an existing colu
- Schema.without() argument {name!r} has to refer to an existi
- Failed to detect the region of S3 bucket {bucket!r} (HTTP st
- SchemaRegistryHeader.value must be a str, got {type(self.val
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/079042d89b53236f.
Report an issue: GitHub.