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.
- Add the column to the process view.
-
Register the process again with the longer
feature_nameslist. The same view keeps itsPROCESS_ID.
(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.
- 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. Passrun_now=Falseto register without running. -
Replay the history from the first date of the calendar:
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.
- 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. REPLACE VIEWthe changed view.-
Record the change and look at the versions. The next
upload_featuresorrun()captures the new SQL as a version; to do it now:
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
```
-
Re-document what the change touches (the object and everything downstream):
-
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:
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:
-
Plan. It lists the dependents in the order they must be removed:
-
Write the script. It is a dry run until you pass
--apply: -
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.
Remove a data domain¶
When: a project is abandoned, or a domain was created by mistake (a typo in
DATA_DOMAIN, a test run).
There is no single call for this, on purpose: a data domain is not an object of its own.
It is the DATA_DOMAIN value carried by process and feature catalog rows, and
tdfs4ds.get_data_domains() lists it as long as one such row exists. Removing a domain
means removing what is in it, with the same guarded removal as above, so that every
dependent is seen before anything goes.
-
Plan the removal of every process of the domain, with their features and the datasets that read them:
dom = 'MY_DOMAIN' pids = tdfs4ds.domain_processes(dom) # processes of the domain, primary store only plan = tdfs4ds.plan_removal(pids, purge_values=True, drop_views=True) for s in plan['steps']: print(s['action'], s['object']) print(plan['unverified']) # reads that failed: resolve them firstRead the steps before going further. A dataset is in the plan when it reads a feature of the domain, including a dataset of another project that joins these features with its own: decide whether it goes, or rebuild it without them first (
rebuild_dataset).purge_values=Truealso deletes the stored values (cannot be undone); without it theFS_T_*rows stay, invisible to every catalog.drop_views=Truedrops the process views; leave it out to keep their SQL. -
Write the script, read its dry run, then apply it:
python tdfs4ds_removal_<timestamp>.py # what each step would remove python tdfs4ds_removal_<timestamp>.py --apply # removes, in order; stops at the first failureThe script checks afterwards that nothing is left and exits with code 2 if something is.
-
Features registered in the domain with no process (their process was removed alone, with
remove_process) are not in that plan. List what is left and remove it the same way: -
Remove the domain's clock setting, if it has one:
print(tdfs4ds.get_domain_time_manager(dom)) # note the clock before removing it tdfs4ds.detach_domain_time_manager(dom, dry_run=True) tdfs4ds.detach_domain_time_manager(dom)This removes the setting only; the clock's own view and table of dates stay (they are yours: drop them by hand once no other domain reads them;
get_descendantson the clock's view tells you). The TimeManager objects of the removed processes are handled by step 1: withdrop_views=Truethe plan adds adrop_time_managerstep for each soft clone (<process view>_TM) or own manager that only the removed processes use (its view, and its_HIDDENtable when nothing else reads it). A manager still read by a remaining process, dataset or view, a domain clock, and a manager whose readers could not be read from the lineage are not dropped; the last are listed underunverified, the others underkept_time_managers. Withoutdrop_viewsthe plan is unchanged and they stay. -
Check:
tdfs4ds.get_data_domains()no longer lists the domain, and a cheaptdfs4ds.sanity_check()reports no lineage gap left by the removal.
The admin app writes the same script in one go: Remove objects (admin and data engineer profiles), choose the domain, Plan the removal of this whole domain, read the plan, then ⬇ Removal script. It puts steps 1, 3 and 4 in one plan (the clock setting is the last step); 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:
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 |
|---|---|---|
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 |