Skip to content

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. Several explode() calls on one array share a single explode.
  • Literal types for arguments Spark only accepts from a fixed set: tsf.TimeUnit, tsf.TimestampAddUnit, tsf.DateTruncFormat, tsf.TruncFormat, tsf.DayOfWeek and ts.JoinType. A misspelled unit or join type is a type error.
  • Python 3.14 support (with PySpark 4.0 or later).
  • A clear ExplodeAccessError for arr.explode(...) in withColumn, pointing to tsf.explode(arr). Spark used to fail with an unresolved internal column.
  • Documentation site at typespark.dev.

Changed

  • breaking TypedColumn, BaseDataFrame, TypedArrayType and ArrayOf are renamed to Column, DataFrame, Array and Array[T].
  • breaking Reading a field off an exploded element moves into access: df.a.explode().id becomes df.a.explode(lambda x: x.id). Exploding two arrays in one constructor raises ExplodeAccessError.
  • breaking Units, formats and days are uppercase and typed ("DAY", "MONDAY"); join types take ts.JoinType.
  • breaking Columns no longer carry names. select(df.arr.explode()) needs an explicit .alias(); dropDuplicates(subset) and withWatermark only accept columns of a typed DataFrame.
  • Columns hash by identity, alias() keeps the column's class, and from_json works on any column.

Removed

  • breaking Column expressions as default= in ts.field and ts.decimal; use factory=.
  • breaking ts.string_literal, ts.int_literal and ts.bool_literal (deprecated in 1.x); call the type instead, e.g. ts.String("x").
  • breaking _set_name(), _set_column(), AliasedTypedColumn and UnnamedColumnError.
  • breaking The data contract CLI: the typespark command, typespark.data_contract and the typespark[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 UnsupportedSparkFeatureError instead of failing inside Spark.
  • select and similar methods accept any typed column.
  • mypy understands the model constructor's DataFrame argument (Model(df, column=...)).
  • ts.decimal accepts 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 of Array[T].

1.3.0

Added

  • withColumn accepts typed columns.

Fixed

  • tsf.collect_list and tsf.collect_set work as aggregates again.
  • A MissingColumnError for a nested field names the struct field to fix.
  • The package type checks cleanly with mypy.
  • The data contract CLI installs as the datacontract extra.

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.over and DataFrame.qualify().
  • StringOf and IntOf for columns restricted to a set of values.
  • TimestampNTZ, Column.between(), DataFrame.crossJoin(), and filter with a function.
  • Typed higher-order array functions: tsf.filter, tsf.aggregate and tsf.transform (with the element index).
  • tsf.regexp_extract_all, tsf.sum_distinct, and ignorenulls for tsf.first and tsf.last.
  • Literal defaults typed from the field's annotation, converters applied to defaults as in attrs, and attrs.Factory defaults.

Fixed

  • Result types of tsf.round, tsf.ceil, tsf.floor and tsf.sum.
  • Comparing an enum column with a plain column is a type error.