Schema Converter (runtime.schema_converter)¶
Bidirectional conversion between SchemaDefinition and PySpark StructType.
Provides to_struct_type and from_struct_type for converting between
the framework’s platform-independent schema model and PySpark’s native types.
PySpark imports are deferred to function bodies so the module can be imported
without a Spark runtime.
- pyspark_pipeline_framework.runtime.schema_converter.to_struct_type(schema)[source]¶
Convert a
SchemaDefinitionto a PySparkStructType.- Parameters:
schema (SchemaDefinition) – The framework schema definition.
- Returns:
A PySpark
StructTypewith corresponding fields.- Raises:
ValueError – If any field type cannot be mapped to a PySpark type.
- Return type:
StructType
- pyspark_pipeline_framework.runtime.schema_converter.from_struct_type(struct_type, description=None)[source]¶
Convert a PySpark
StructTypeto aSchemaDefinition.- Parameters:
struct_type (StructType) – A PySpark
StructType.description (str | None) – Optional description for the resulting schema.
- Returns:
A
SchemaDefinitionwith corresponding fields.- Return type: