yggdrasil.data.types.nested.struct_spark¶
struct_spark ¶
Spark cast helpers for :class:StructType targets.
Spark casts lower to :class:pyspark.sql.Column expressions —
projection-time, no row-by-row work. The cast becomes part of the
physical plan, fused with any pushdown filters and the final
select(*cols).
- :func:
cast_spark_struct_column— struct → struct viaF.struct(...), with a null-preservation guard (F.when(col.isNull(), F.lit(None)).otherwise(...)) becauseF.structalways returns a non-null row. - :func:
cast_spark_map_column— map → struct viaF.element_at(col, F.lit(name))per child. - :func:
cast_spark_list_column— list → struct viaF.get(col, F.lit(i))(null-on-OOB; plaincol[i]raisesArrayIndexOutOfBoundsExceptionin Spark 4.x). - :func:
cast_spark_tabular— DataFrame select with one cast Column per target field.