Trigger a Function from a Table Commit
By default, functions trigger when any of their input tables receives new data. The trigger_by parameter lets users specify a subset of input tables that should trigger the function instead, or disable automatic triggering entirely.
Needs a transformer. Getting its guide.
Called tabsdata 2 times (ctrl+o to expand)
Generating — trigger_by narrows the default trigger set to orders alone. regions is still read on every run and still supplies its current data, it just no longer starts one.
Called tabsdata 3 times (ctrl+o to expand)
The transformer, registered in sales:
@transformer(
input_tables=["orders", "regions"],
output_tables=["orders_by_region"],
trigger_by=["orders"],
)
def summarize(orders: TableFrameSpec, regions: TableFrameSpec) -> TableFrameSpec:
return orders.group_by("region").agg(col("amount").sum())
This is not about avoiding duplicate runs. A plan that commits both tables runs the transformer once either way, since the plan covers every downstream function and orders them by dependency rather than firing one run per committed table.
Needs a transformer. Getting its guide.
Called tabsdata 2 times (ctrl+o to expand)
Generating — trigger_by names purchases alone. input_tables and trigger_by are independent lists: orders and regions are both read but silent, and purchases starts a run despite never being read.
Called tabsdata 3 times (ctrl+o to expand)
The transformer, registered in sales:
@transformer(
input_tables=["orders", "regions"],
output_tables=["orders_by_region"],
trigger_by=["purchases"],
)
def summarize(orders: TableFrameSpec, regions: TableFrameSpec) -> TableFrameSpec:
return orders.group_by("region").agg(col("amount").sum())
A publisher uses the same mechanism. It has no input tables at all, so naming a table in trigger_by is the only way a Tabsdata commit can start it.
collection/table references work within one project. A reference to a table in another project reports Dependency table '<x>' does not exist, because row-level security hides it rather than reporting it as forbidden.
Needs a transformer. Getting its guide.
Called tabsdata 2 times (ctrl+o to expand)
Generating — an empty trigger_by. Orders and regions are both still read as inputs, and neither commit starts a run any more.
Called tabsdata 3 times (ctrl+o to expand)
The transformer, registered in sales:
@transformer(
input_tables=["orders", "regions"],
output_tables=["orders_by_region"],
trigger_by=[],
)
def summarize(orders: TableFrameSpec, regions: TableFrameSpec) -> TableFrameSpec:
return orders.group_by("region").agg(col("amount").sum())
This runs only when triggered directly, with tdk fn trigger.