Editing Datasets
Most of the time, datasets and/or their attributes should be referenced "as-is" in action configs. However, there are cases where datasets need to be edited, for example:
Specifying primary and foreign keys on data sourced from object stores (where such metadata does not exist as it does in a relational database)
Removing a foreign key to break a cyclic relationship between multiple tables
The dataset_editor
action provides a way to apply alterations like these to datasets. It accepts a dataset from some other action as input, and outputs a modified version of that dataset for downstream actions to consume.
Adding and removing table relationships
A table relationship is used to relate two tables. The most common example is a foreign key constraint in a relational database.
A table_relationship
may contain the following properties
table | string | The name of the table containing data (typically an id column) pointing to records on another table, e.g. "the table with the foreign key" |
constrained_columns | string list | The columns populated with identifiers from the other table, e.g. "the foreign key column(s)" |
referred_table | string | The name of the table containing data records being referenced by |
referred_columns | string list | The columns to which |
For example, a relational database storing users
and their sessions
might have a foreign key user_id
on the sessions
table pointing to the users.id
column. That key can be represented as a table_relationship
:
To add or remove relationships via the dataset_editor
action, use the add_table_relationships
and remove_table_relationships
attributes, both of which accept a table_relationship
list.
Removing or renaming tables
Tables in a dataset can be removed entirely, or renamed.
Setting primary keys
Primary keys can be specified on tables.
Combining operations
All dataset modifications above can be performed in a single action. The order of operations is:
drop_tables
rename_tables
set_primary_keys
remove_table_relationships
add_table_relationships
Last updated