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
Transformer Code Anatomy
1from tabsdatak.api import transformer, TableFrameSpec2import tabsdatak.api.tableframe as tdf341@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.
Nonewhen that version doesn't exist.Turns the input frames into the output frame.
One frame per output table, in order.
Nonekeeps the current version.
For step-by-step guidance on building a transformer, see Transformers under How-to Guides.