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. REPLACE VIEW the changed view.
  2. 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.dependencies.verify_removal(plan) runs the same check alone.

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.

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.

Keep statistics, lineage, documentation and the index current

What Call Why
Optimizer statistics of the FS_T_* tables tdfs4ds.check_storage_statistics() (read only), then add_missing=True, 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