Changelog¶
All notable changes to TypeSpark. The format follows Keep a Changelog, and TypeSpark follows the version policy.
It covers every release on PyPI, from 1.1.0 on.
2.0.0a1¶
The first 2.0 pre-release. Changes marked breaking have a section with what to change in Migrating from 1.x.
Added¶
Array[T].explode(access): build model columns from an exploded element, with typed access to its fields. Severalexplode()calls on one array share a single explode.Literaltypes for arguments Spark only accepts from a fixed set:tsf.TimeUnit,tsf.TimestampAddUnit,tsf.DateTruncFormat,tsf.TruncFormat,tsf.DayOfWeekandts.JoinType. A misspelled unit or join type is a type error.- Python 3.14 support (with PySpark 4.0 or later).
- A clear
ExplodeAccessErrorforarr.explode(...)inwithColumn, pointing totsf.explode(arr). Spark used to fail with an unresolved internal column. - Documentation site at typespark.dev.
Changed¶
- breaking
TypedColumn,BaseDataFrame,TypedArrayTypeandArrayOfare renamed toColumn,DataFrame,ArrayandArray[T]. - breaking Reading a field off an exploded element moves into
access:df.a.explode().idbecomesdf.a.explode(lambda x: x.id). Exploding two arrays in one constructor raisesExplodeAccessError. - breaking Units, formats and days are uppercase and typed (
"DAY","MONDAY"); join types takets.JoinType. - breaking Columns no longer carry names.
select(df.arr.explode())needs an explicit.alias();dropDuplicates(subset)andwithWatermarkonly accept columns of a typed DataFrame. - Columns hash by identity,
alias()keeps the column's class, andfrom_jsonworks on any column.
Removed¶
- breaking Column expressions as
default=ints.fieldandts.decimal; usefactory=. - breaking
ts.string_literal,ts.int_literalandts.bool_literal(deprecated in 1.x); call the type instead, e.g.ts.String("x"). - breaking
_set_name(),_set_column(),AliasedTypedColumnandUnnamedColumnError. - breaking The data contract CLI: the
typesparkcommand,typespark.data_contractand thetypespark[datacontract]extra. TypeSpark no longer depends on pyyaml.
Fixed¶
- Assigning a struct aggregate to a model field no longer raises
FrozenInstanceError.
1.5.0¶
Changed¶
- Support PySpark up to 4.3 (
pyspark>=3.5.2,<4.4).
1.4.2¶
Fixed¶
- Spark 3.5 support: functions that need Spark 4.0 raise
UnsupportedSparkFeatureErrorinstead of failing inside Spark. selectand similar methods accept any typed column.- mypy understands the model constructor's DataFrame argument (
Model(df, column=...)). ts.decimalaccepts an integer default together with a typed converter.
1.4.1¶
Fixed¶
- After
from_df, columns filled from a default refer to the built column instead of repeating the default expression. - The package type checks cleanly with pyright, now enforced in CI.
1.4.0¶
Deprecated¶
ArrayOf(T), in favour ofArray[T].
1.3.0¶
Added¶
withColumnaccepts typed columns.
Fixed¶
tsf.collect_listandtsf.collect_setwork as aggregates again.- A
MissingColumnErrorfor a nested field names the struct field to fix. - The package type checks cleanly with mypy.
- The data contract CLI installs as the
datacontractextra.
1.2.0¶
Added¶
- Decimal precision and scale for
Array[Decimal]columns.
1.1.0¶
The first release on PyPI, published from release tags from now on. Highlights:
Added¶
Model.create(): build a typed DataFrame from local data.Model.lazy(): a typed DataFrame with columns and no data, for building conditions.- Typed window functions:
ts.Window,Column.overandDataFrame.qualify(). StringOfandIntOffor columns restricted to a set of values.TimestampNTZ,Column.between(),DataFrame.crossJoin(), andfilterwith a function.- Typed higher-order array functions:
tsf.filter,tsf.aggregateandtsf.transform(with the element index). tsf.regexp_extract_all,tsf.sum_distinct, andignorenullsfortsf.firstandtsf.last.- Literal defaults typed from the field's annotation, converters applied to defaults as in
attrs, and
attrs.Factorydefaults.
Fixed¶
- Result types of
tsf.round,tsf.ceil,tsf.floorandtsf.sum. - Comparing an enum column with a plain column is a type error.