Skip to main content
Version: 2.0.0

Transformers

A transformer function reads data from one or more tables in the Tabsdata server, transforms the data, then writes the transformed data to tables in the server.

Transformers in Action

collection · world
collection · insights · data product
Table
country
//world
Committed
Table
city
//world
Committed
Transformer
find_big_cities
Table
big_cities
//insights
No versions yet

Transformer Code Anatomy

find_big_cities.py
1from tabsdatak.api import transformer, TableFrameSpec
2import tabsdatak.api.tableframe as tdf
3
4
1@transformer(
2 input_tables=["world/country", "world/city"],
3 output_tables=["big_cities"],
8)
45def find_big_cities(country: TableFrameSpec, city: TableFrameSpec) -> tuple[TableFrameSpec]:
6 countries = country.rename({"name": "country_name"}).drop(
11 ["population", "continent"]
12 )
13 joined = city.join(countries, left_on="country_code", right_on="code")
7 return (joined.filter(tdf.col("population") > 3_000_000),)
  • Declares the tables to read and the tables to write. No connector; transformers are table-to-table.

    • Tables to read, as collection/table, mapped positionally to function body arguments.

    • Tables this function commits, one per returned frame, always in its own collection.

  • Plain Python over TableFrames: joins, aggregations, filters, reshaping.

    • One parameter per input table, in order. None when that version doesn't exist.

    • Turns the input frames into the output frame.

    • One frame per output table, in order. None keeps the current version.

For step-by-step guidance on building a transformer, see Transformers under How-to Guides.