Skip to content

Maintain a workflow

A workflow changes after it goes live: a feature is added, a process is rewritten, a feature is retired, a table needs another primary index. Each recipe below says when to use it, the steps, and what to check afterwards.

All recipes stay inside the framework: processes are registered with upload_features and refreshed with run() / roll_out(). Never write to FS_T_* or the catalogs by hand, and never loop around run() in your own code.

Add a feature to a process

When: the process view gains a column you want as a feature.

  1. Add the column to the process view.
  2. Register the process again with the longer feature_names list. The same view keeps its PROCESS_ID.

    pid = tdfs4ds.upload_features(
        df='MY_DB.FEAT_ENG_CUSTOMER',                   # the process view
        entity_id=['CUSTOMER_ID'],
        feature_names=['amount_sum', 'amount_max'],     # 'amount_max' is new
        run_now=False, return_process_id=True)
    

(df can be the 'schema.view' name, as here, or the DataFrame of the view.) 3. The new feature has no history. A history is built forward only, so replay it from the first date. With a TimeManager:

```python
tdfs4ds.roll_out([pid], time_manager=tm, time_id_start=1, force_compute=True)
```

Without one, tdfs4ds.run(pid, force_compute=True) computes the current time only.

Types. A registered feature keeps its stored type. If the source type no longer fits, upload_features registers nothing, returns None and the log gives the options: CAST in the view, or widen the stored type for every producer with tdfs4ds.plan_type_change(process_id=pid) (see Relocating features). The text length of new text features is rounded up to a multiple of force_varchar_length (default 1024, recorded per process; change it with tdfs4ds.set_process_options(pid, force_varchar_length=2048)).

Check: tdfs4ds.get_process_info(pid)['FEATURE_COLUMNS'] lists the feature, and the follow-up shows COMPLETED rows for every date.

Add a process

When: a new feature-engineering view for an entity.

  1. Register it with upload_features(...). If the data domain has a domain clock and the view reads it, the process gets its own soft clone of the clock, with a log line. Pass run_now=False to register without running.
  2. Replay the history from the first date of the calendar:

    tdfs4ds.roll_out(data_domain='SALES')
    

For a process outside a domain clock, use roll_out([pid], time_manager=tm). 3. Refresh the lineage so the checks and the execution plan know the process:

```python
tdfs4ds.rebuild_lineage_graph(objects=['MY_DB.NEW_VIEW'], check=True)
```

Check: the process appears in the execution plan (tdfs4ds.analyze_parallel_plan()), and tdfs4ds.sanity_check() shows nothing new for it (see Assess workflow health).

Change the SQL of a process

When: you edit the process view, or a view it reads.

  1. Study the impact first: tdfs4ds.impact_of('MY_DB.CHANGED_VIEW', new_sql=...) lists who reads the view, what the new SQL breaks or changes, and the calls to make afterwards. See Study the impact of a change.
  2. REPLACE VIEW the changed view.
  3. Record the change and look at the versions. The next upload_features or run() captures the new SQL as a version; to do it now:

    tdfs4ds.capture_process_sql([pid], dry_run=False)
    tdfs4ds.process_sql_versions(pid)
    print(tdfs4ds.process_sql_diff(pid, 1, 2))
    

See Process versions. 3. Refresh the lineage of the edited objects and check that everything downstream still compiles:

```python
tdfs4ds.rebuild_lineage_graph(objects=['MY_DB.CHANGED_VIEW'], check=True)
tdfs4ds.check_downstream_processes(['MY_DB.CHANGED_VIEW'])   # EXPLAIN on each downstream process
```
  1. Re-document what the change touches (the object and everything downstream):

    tdfs4ds.rebuild_documentation(objects=['MY_DB.CHANGED_VIEW'])
    
  2. Recompute. Values already stored stay as they were computed. To bring the history in line with the new logic, replay every date, then the processes downstream of it:

    tdfs4ds.roll_out([pid], time_manager=tm, time_id_start=1, force_compute=True)
    

Downstream processes recorded COMPLETED on the old values, so they are skipped unless you force them (force_compute=True).

Check: sql_drift and history_mixes_versions in the workflow assessment. A history computed under several SQL versions is reported as information.

Retire a feature, or remove a process with its features

When: a feature is no longer wanted, or a whole process goes.

Removals are refused when something depends on the object, and planned instead:

  1. Plan. It lists the dependents in the order they must be removed:

    plan = tdfs4ds.plan_removal(['<process id>'])      # also view names, datasets, features
    for s in plan['steps']:
        print(s['action'], s['object'], '<-', s['reason'])
    
  2. Write the script. It is a dry run until you pass --apply:

    path = tdfs4ds.write_removal_script(plan)
    
    python tdfs4ds_removal_<timestamp>.py            # what each step would remove
    python tdfs4ds_removal_<timestamp>.py --apply    # removes, in order; stops at the first failure
    
  3. The script checks afterwards that nothing is left (catalog rows, documentation, provenance, stored SQL versions, vector-index entries) and exits with code 2 if something is. tdfs4ds.verify_removal(plan) runs the same check alone.

From Python, apply the plan you read instead of writing a script (0.3.8.17). With owned_only=True the plan removes only what the objects own: a process of another author, a dataset that also reads another process's features, a feature another process computes, a manager something else reads and the domain clock are listed under plan['kept'] with the reason, never removed. The process's own soft clone and FilterManager go with it.

plan = tdfs4ds.plan_removal(['<process id>'], drop_views=True, owned_only=True)
for k in plan['kept']:
    print(k['kind'], k['object'], '-', k['reason'], '(blocking)' if k['blocking'] else '')
tdfs4ds.apply_removal(plan)                          # exactly these steps, then verify_removal

apply_removal writes nothing when the plan is blocked (a kept object would be left broken: add it to the objects, or change it), when one of its reads failed, or when the store changed since it was read: it plans the same request again, compares the plan's fingerprint, and raises tdfs4ds.StaleRemovalPlanError naming what changed. Plan again, read, apply.

Called directly, remove_process, remove_feature and remove_dataset raise tdfs4ds.DependentObjectsError when something depends on the object. To remove one feature of a process that other processes also compute, scope it:

tdfs4ds.remove_feature('amount_max', entity_id=['CUSTOMER_ID'],
                       data_domain='SALES', process_id=pid)

With process_id=, the catalog entry goes only when no other process computes the feature. Stored values are kept unless the plan was made with purge_values=True. Every removal and refusal is a row of tdfs4ds.get_removal_log(). Details: Inspect & monitor.

Remove a data domain

When: a project is abandoned, or a domain was created by mistake (a typo in DATA_DOMAIN, a test run).

A data domain is not an object of its own: it is the DATA_DOMAIN value carried by process and feature catalog rows, plus its settings (clock, calendar gaps). Removing it means removing what it owns, with the guarded removal above.

A disposable domain: one call (0.3.8.17). A domain created for an experiment with create_data_domain(dom, disposable=True) (or declared later with set_data_domain_disposable(dom, True)) is removed in one call:

dom = 'TMP_EXPERIMENT'
plan = tdfs4ds.remove_data_domain(dom)                  # dry run: prints the plan, writes nothing
tdfs4ds.remove_data_domain(dom, dry_run=False)          # removes it (purge_values=True by default)

It removes feature-store objects only (never the source tables) and never touches a read-only store. Shared objects are kept and listed; a plan that would break another domain's object is refused. set_data_domain_disposable(dom, False) keeps an experiment: the one-call removal then refuses it.

A real domain: plan, read, apply. Any other domain is refused by remove_data_domain.

  1. Plan the removal of the whole domain. It is the owned-only plan of every process of the domain and of its features with no process, then its clock, its settings rows and, with purge_values=True (the default, as for remove_data_domain), the stored values and the storage tables left empty:

    dom = 'MY_DOMAIN'
    plan = tdfs4ds.plan_domain_removal(dom, purge_values=True)     # read only
    for s in plan['steps']:
        print(s['action'], s['object'])
    for k in plan['kept']:
        print('kept:', k['kind'], k['object'], '-', k['reason'], '(blocking)' if k['blocking'] else '')
    print(plan['unverified'])                       # reads that failed: resolve them first
    

    Read the steps before going further. A dataset of another project that joins this domain's features with its own is kept and blocks the plan: decide whether it goes (add it to a plan_removal of its own first) or rebuild it without them (rebuild_dataset). The default purge_values=True deletes the stored values (cannot be undone); with purge_values=False the FS_T_* rows stay, invisible to every catalog.

  2. Apply it:

    tdfs4ds.apply_removal(plan)
    

    It refuses a plan the store changed under since you read it (StaleRemovalPlanError: plan again), runs exactly the plan's steps, then checks that nothing is left. The domain clock goes with the domain (its view, its table of dates, its registry row and calendar rule) unless another domain or a remaining object reads it, in which case it is kept and listed. The soft clones and managers of the removed processes go when nothing else reads them; a manager whose readers could not be read from the lineage is kept and listed.

    The same plan as a script, for a review outside Python: tdfs4ds.write_removal_script(plan), then python <script> --apply.

  3. Check: tdfs4ds.get_data_domains() no longer lists the domain, and a cheap tdfs4ds.sanity_check() reports no lineage gap left by the removal.

The admin app writes a removal script for a whole domain: Remove objects (admin and data engineer profiles), choose the domain, Plan the removal of this whole domain, read the plan, then ⬇ Removal script. The app itself removes nothing.

Change the primary index, the partitioning, or give a feature its own table

When: skew, a primary index that does not match the source, two processes of one entity serialised by a shared table, or a column type that must grow.

plan = tdfs4ds.plan_relocation(process_id=pid, table_tag='SALES')          # read only
plan = tdfs4ds.plan_relocation(process_id=pid, primary_index=['CUSTOMER_ID'])
print(plan['blocking'], plan['cost'])
tdfs4ds.relocate_features(plan, dry_run=True)       # what each step would do
tdfs4ds.relocate_features(plan, dry_run=False)      # apply
tdfs4ds.verify_relocation(plan)                     # read only

The history is copied and verified before the old rows are deleted (the last step), and the datasets that read the features are rewritten and checked. The free perm of the database must hold both copies until the delete. See Relocating features.

Check a history after a replay

After roll_out(data_domain=..., time_id_start=1, force_compute=True) (or roll_out([...], ...)), run the cheap sanity checks on the processes replayed:

tdfs4ds.sanity_check('after_replay.html', processes=['<PROCESS_ID>'], scope='cheap')

What to look at:

Look at Check or finding Good result
One COMPLETED follow-up row per process and date tdfs4ds.completed_dates(pids), segments check no missing date, no FAILED segment
Empty dates COMPLETED,0 rows (column EMPTY of completed_dates) none, or each one explained
Dates in order order check no process computed before its upstream or ahead of it
No validity gap validity_gap_without_flag; it reads storage: scope='full', or process_usage_for(pid, closed=True) none: a run leaves no gap
Absent entities closed_entities, when close_absent_entities=True only the expected entities are closed
The domain roll-out rollout_refused, manager_shared_across_domains absent

Fix the first finding of a process before the next replay: a replay rewrites every date from the first one. See Assess workflow health.

Keep statistics, lineage, documentation and the index current

What Call Why
One-off steps after an upgrade tdfs4ds.upgrade_store() (dry run: what the store still owes, and why), then upgrade_store(dry_run=False) Since 0.3.7.37. connect() logs a line when a step is pending
Optimizer statistics of the FS_T_* tables tdfs4ds.check_storage_statistics() (read only), then add_missing=True, fix_options=True (once after upgrading to 0.3.7.36), refresh=True Without statistics Teradata can misestimate dataset queries by orders of magnitude
Persisted lineage graph tdfs4ds.rebuild_lineage_graph(all_data_domains=True); objects=[...] for edited objects only The order checks, check_upstream and the execution plan read it
Documentation tdfs4ds.rebuild_documentation(force_update=False) Documents what is not yet documented; also refreshes the lineage and the index
Vector index tdfs4ds.rebuild_vector_indexing(force_rebuild=True) The consumer agent searches it
Process SQL versions tdfs4ds.capture_process_sql(all_processes=True, dry_run=False) Stores the SQL of processes not captured yet

The admin app's Maintenance panel runs each of these, or all of them in a chain, with a live log.

A schedule that works for most stores:

When What
After every change rebuild_lineage_graph(objects=[...], check=True), sanity_check()
Daily the refresh of the data (run(data_domain=...)), the cheap sanity checks
Weekly rebuild_documentation(), check_storage_statistics(), the storage checks of the sanity check (scope='full')
Before a migration sanity_check(scope='full'), then plan_migration