fs-workflow-assessment¶
Assess how a pipeline is built: entity keys, run order, point-in-time leakage, segments, storage skew, primary index and partitioning. Returns findings as data. For a one-call report use fs-sanity-check.
name: "Feature Store: Workflow assessment"
description: "Generate code to assess how a tdfs4ds pipeline is built: entity keys with columns the other key columns determine, processes run before their upstream or not recomputed after it, TimeManager processes reading current datasets (point-in-time leakage), missing or failed FilterManager segments, process SQL changed without a run, storage skew, primary index and partitioning against the largest source (EXPLAIN evidence), FilterManager segments that do not follow the source partitioning. Deterministic, no language model. Invoke when the user asks whether the pipeline, the entity choice, the primary index / partitioning or the run order is right. SKIP for a one-call health report and its verdict (use fs-sanity-check), for catalog/storage consistency and orphans (use fs-inspect) and for the performance of one process (use fs-analyze)."
argument-hint: "[data-domain][processes]"
allowed-tools: "Read, Edit, Write, Bash, Glob, Grep"
Generate Python code that assesses how the tdfs4ds workflow is built, and explain the findings.
User context: $ARGUMENTS
Related skills¶
| Step | Skill | Why |
|---|---|---|
| Before | fs-setup |
Connect first if no Teradata context is open. |
| Before | fs-lineage |
The order and leakage checks read the persisted lineage graph. |
| Fix | fs-rollout |
Re-run in the right order, rebuild a history with force_compute=True. |
| Fix | fs-dataset |
Rebuild a dataset with time_manager= when it leaks. |
| Start | fs-sanity-check |
One call for the report, how to read it, whether a process can be refreshed. |
| Compare | fs-inspect |
Catalog/storage consistency, orphans, removal. |
To run the checks and get the report in one call:
import tdfs4ds
tdfs4ds.connect(database='<DATABASE>')
tdfs4ds.sanity_check('sanity.html') # a .md path writes Markdown
tdfs4ds.sanity_check('sanity.md', scope='full') # adds the entity and dataset scans
The default scope is the checks a migration report runs, and the report names the checks it left out. Use assess_workflow below for the findings as data, or to set the follow-up window and thresholds.
Ask for any missing values before generating code:
- Data domain(s) — or all of them.
- Processes — ids or view names, or every process.
- Storage reads — entity_scan (one grouped pass per entity over its largest table), dataset_rows and closed_entities read the storage tables; switch them off on a very large store when only the run order is in question.
import tdfs4ds # reads the TDFS4DS_* settings of .env
tdfs4ds.connect(database='<DATABASE>')
report = tdfs4ds.assess_workflow(
data_domains=['<DATA_DOMAIN>'], # None = every domain
processes=None, # or ['<process id or view name>', ...]
entity_scan=True, # these three read the storage tables;
dataset_rows=True, # all False = no read of them
closed_entities=True,
days=90, # follow-up window of the run checks
)
report['counts'] # {'error': n, 'warning': n, 'info': n}
for f in report['findings']: # area, kind, object, detail, severity, fix
print(f['severity'], f['kind'], f['object'])
print(' ', f['detail'])
print(' fix:', f['fix'])
report['unverifiable'] # checks that could not run, with the reason
The executive summary is in report['health']: verdict, top_issues, and rows (one per process, ordered by
execution wave, a cell per dimension with the worst severity, ok or n/a = not checked). Export it:
tdfs4ds.write_workflow_report(report, fmt='html') # standalone page; 'md' for a wiki, 'csv' for the findings
Demo: demos/notebooks/A3 - Assessing the workflow.ipynb.
The lineage graph must be persisted for the order and leakage checks; when it is empty they are listed under unverifiable, never reported as passing:
What each finding means¶
| Area | Kind | Meaning | Usual fix |
|---|---|---|---|
| lineage | dataset_reads_removed_process |
A dataset still reads the values of a process no longer registered: it returns what that process last wrote, never refreshed. The finding names the dead branch (and, from FS_REMOVAL_LOG, the removed view, when and by whom). |
Rebuild the dataset on a registered process, or remove the branch: tdfs4ds.write_removal_script(tdfs4ds.plan_removal(['<removed pid>'])). |
| lineage | dataset_reads_removed_feature |
A dataset reads a feature no longer in the catalog. | Rebuild it on current features, or remove it (plan_removal). |
| lineage | dataset_reads_stale_table |
A dataset reads a feature from a storage table the catalog no longer uses for it (a type change moves a feature to another table on the next run, no history copy). The view still compiles; it returns frozen values, then none. Shows old -> new. |
Rebuild the dataset on the current features (build_dataset takes each table from the catalog); or tdfs4ds.rewrite_dataset_tables('<dataset>') for a dry run, then dry_run=False. |
| lineage | dataset_reads_missing_table |
A dataset reads a storage table that no longer exists. | Restore the table, or rebuild the dataset on current features. |
| lineage | dataset_feature_no_rows |
Check dataset_rows (reads the storage tables, on by default in assess_workflow; dataset_rows=False skips it, and so does sanity_check's default scope): the table holds no row for the feature's FEATURE_ID and process version at the valid time the dataset reads. INNER dataset: no row at all (error); FULL OUTER: the column is all NULL (warning). The follow-up tells "process never completed" from "rows gone". |
tdfs4ds.run('<pid>') when it never ran, run(..., force_compute=True) once the cause of missing rows is known, or rebuild the dataset without the feature. |
| lineage | dataset_reads_other_store |
Information: a dataset reads features stored in another feature store, whose processes are not checked from this one. | connect(..., databases_readonly=[...]) and assess again. |
| lineage | feature_without_process |
A registered feature no process computes any more. | Register a process computing it again, or plan_removal([(name, [entity], domain)]). |
| lineage | process_view_missing / dataset_view_missing |
A catalog row whose view is gone. | Recreate the view, or plan_removal. |
| lineage | process_reads_missing_object / process_view_broken |
The process view reads an object that no longer exists, or no longer compiles (EXPLAIN). | Restore the object, or remove the process and its dependents (plan_removal). |
| lineage | process_reads_unregistered_dataset |
The process view reads a dataset view no longer in the dataset catalog. | restore_dataset_catalog(dry_run=True), or rewrite the process view. |
| lineage | lineage_edge_to_unknown |
The lineage graph links a dataset to a view that is no registered process. | rebuild_lineage_graph(objects=[...], check=False). |
| lineage | view_does_not_compile |
Check network (0.3.4.0): EXPLAIN runs on EVERY process view, dataset view and view of the lineage graph. Only the root failure is reported (the views reading it fail with it, listed under it), with the processes and datasets it stops. |
Fix or restore the view (SHOW VIEW gives its text). |
| lineage | view_not_verifiable |
EXPLAIN refused for lack of a right (0.3.4.5): the view may be fine, nothing below it was checked (warning, never view_does_not_compile). |
The GRANT the finding names (ask the owner or a DBA). |
| lineage | views_not_compiled |
Information: more views than the network check compiles; those over the limit were not checked. |
Assess with processes= or data_domains=. |
| lineage | lineage_stops_no_access / lineage_not_recorded / lineage_stops_unreadable |
A view of the lineage graph with nothing recorded below it: its definition cannot be read by this user (SHOW VIEW refused), or it reads objects the graph lacks, or SHOW VIEW fails. The finding names the processes and datasets whose lineage, impact analysis and checks end there. Objects absent from DBC.TablesV are probed too: that view lists only objects the user has a right on. | The GRANT named, then rebuild_lineage_graph(objects=['<view>'], check=True). |
| lineage | process_reads_inaccessible_object |
Integrity check: a process reads an object this user cannot see and its EXPLAIN is refused (warning, not process_view_broken). |
The GRANT named, then assess again. |
| lineage | lineage_split |
The lineage is several separate networks (info). Independent pipelines are expected; a process meant to read another one should be in its network. | Check the networks; a missing link: rebuild_lineage_graph(objects=['<view>'], check=True). |
| lineage | lineage_isolated |
A process or dataset with no lineage link: nothing is known of what it reads or what reads it. | rebuild_lineage_graph(objects=['<view>'], check=True). |
| lineage | process_not_read |
Dead end: a process whose view no dataset or process reads. | Build a dataset on it, or plan_removal([pid]). |
| lineage | detached_branch |
Dead branch: views/tables of the lineage that no registered process or dataset reaches (usually left by a removed process). | Drop the unused views, then rebuild_lineage_graph(all_data_domains=True). |
The report's Lineage section always carries a Lineage network block (views compiled, the networks, the dead branches), also when nothing is found. An EXPLAIN error the database did not give (lost session) goes to unverifiable, never to a finding; without the lineage graph only the compilation runs.
| entity | redundant_key_column | Over the whole history, the other key columns are unique without this column: it is determined by them, and a lookup by the real key cannot use the primary index. | Register the processes with the smaller entity_id; keep the column as a feature. |
| entity | key_column_changes_over_time | Determined by the other columns now, but it changed over time: each change started a new entity. | Remove it from entity_id, store it as a feature. |
| entity | entity_key_superset | Two entity keys of one domain, one containing the other: features of one entity may be split. | Run the entity scan, then re-register at the smaller key. |
| storage | entity_column_type_mismatch | An entity column typed differently across tables (e.g. integer vs character): joins convert, rows leave their AMP. | Cast in the process views, re-register. |
| storage | storage_skew | A storage table concentrated on a few AMPs. | Check the entity columns (low-cardinality column in the PI). |
| storage | entity_pi_inconsistent | The storage tables of one entity use different primary indexes: datasets joining them redistribute. | One primary_index= for every process of the entity (re-registration). |
| storage | pi_not_aligned_with_source | The largest source is hashed on columns the view passes as entity columns, and the storage tables are hashed otherwise; the EXPLAIN of the staging step says whether rows are redistributed now and local with the aligned index. | Same index for the whole entity: plan_relocation(process_id=..., table_tag=..., primary_index=[...]) for each process keeps the history (fs-relocate); the finding's own fix, remove + re-register + replay, rebuilds it. |
| storage | partition_not_aligned_with_source | The largest source is partitioned on a column the view passes as an entity column; the storage tables are not. | partitioning= at the re-registration. |
| storage | segments_rescan_source | A FilterManager segments on columns that do not follow the largest source's partitioning: every segment reads all its partitions. Whatever the size: on a small source the finding says it does no harm today, but it will if the table grows. | Segment on the partitioning column (or a coarser bucket) if the business logic allows it: a segment must hold every row its computation needs. |
| storage | segment_filter_defeats_pruning | The FilterManager filters a partitioning column of the source, but even with the segment value known (incremental planning) EXPLAIN reads all its rows: the view SQL prevents pruning. | A scalar filter on the bare column: WHERE src.<col> = (SELECT <col> FROM <filter view>); no function/CAST on the column, no OR with another column. |
| storage | time_filter_by_join / segment_filter_by_join | Warning: the view reads its TimeManager or FilterManager through a join (explicit, a comma list, or a derived table). A manager holding two rows multiplies the view's rows, where a scalar subquery fails. | Use a scalar filter WHERE src.<date> <= (SELECT BUSINESS_DATE FROM <tm view>); exception: views scored on the ACC (tdstone2 / Apply) need the JOIN (Error 6881). |
| storage | time_filter_not_scalar / segment_filter_not_scalar | Warning: the view reads the manager with IN or EXISTS, or through an intermediate view selecting from it. | A scalar filter in the view that uses the value. |
| storage | segment_filter_off_hierarchy | Warning: the FilterManager filters a lower partitioning level of a source (any partitioned source, whatever its size) and nothing filters a level above it. Partitions are still eliminated, but each segment reads a slice across every partition of the skipped level. A TimeManager's scalar filter on that level counts. On a small source it does no harm today, but it will if the table grows, as it may when a process built on a small lab table is migrated. | Add the higher level to the FilterManager's columns, or filter it with the TimeManager, if the business logic allows it. |
| storage | time_filter_not_on_partitioning | The business date is compared with a column the source is not partitioned on. Whatever the size, with the same note on a small source. | Compare it with the partitioning column, if it carries the same date. |
| storage | time_filter_defeats_pruning | A scalar business-date filter on the partitioning column that still prunes nothing with the date known, or (static plan only) a plan that casts the partitioning column to a TIMESTAMP ... WITH TIME ZONE to compare it with the scalar. Whatever the size: a bare scalar prunes on a 0.5 MB table too (measured). | Keep the column bare; put arithmetic on the date inside the subquery (src.d < (SELECT BUSINESS_DATE + 1 FROM tm)), and give the value the column's type (CAST(SUBSTR(CAST(BUSINESS_DATE AS VARCHAR(40)), 1, 19) AS TIMESTAMP(0)) for a TIMESTAMP(0) column: a direct cast is Error 7454 from a TIMESTAMP(6) manager). |
| storage | partitioned_source_read_whole | The plan reads every partition of a partitioned source, whatever the SQL looks like (a join with no filter on the partitioning column, typically). Also for the LARGEST source, unless the TimeManager scalar is on one of its partitioning columns or the FilterManager segments follow it (those have their own findings): a manager that bounds only another column (a key table's date) does not cover the historian. Warning when the process has a manager, since the date or segment is known and restricts nothing; info with none, since it may be meant. | Filter it on its partitioning column with a scalar of that column's type. |
| time | date_computed_before_earlier_date | A business date whose latest run is older than a run at an earlier date: built at the last date, then rolled out without forcing. | roll_out(..., time_id_start=1, force_compute=True). |
| storage | dbc_nearly_full | The fullest AMP of database DBC is at 90% or more: statements then fail with Error 2644 in unrelated calls. | An administrator purges the query log tables or gives DBC more space. |
| storage | fs_partition_not_on_filter | Segments on entity columns, storage tables not partitioned on them: each segment's MERGE probes every partition. | partitioning= at the re-registration. |
| time | ran_before_upstream | At a business date, the process started before its upstream finished. | Run in dependency order (analyze_parallel_plan, generate_execution_script), re-run with force_compute=True. |
| time | upstream_recomputed_after | The upstream was recomputed after the process ran: the process is stale. | roll_out([pid], tm, force_compute=True) over those dates. |
| time | completed_on_failed_upstream | The upstream had failed or written no rows, the process still completed. | Re-run the upstream, then the process with force_compute=True; use check_upstream=True. |
| time | upstream_missing_at_date / ahead_of_upstream | On one timeline, the process computed dates its upstream has not. | Roll the upstream out first. |
| time | process_not_on_domain_clock | The data domain has a clock (0.3.6.0) but the process reads another calendar or none: a roll-out or run of the domain computes it on other dates. | tdfs4ds.align_domain_time_managers('<DOMAIN>', process_ids=['<PID>'], dry_run=True), then dry_run=False. |
| time | processes_share_time_filtered_view | Processes read the domain clock through one view they share (0.3.6.8): none can get its own clone, so they share the clock's cursor (values right; a partial run at another date is seen by the others). | Remove the date filter from the view and filter in each process view (or copy the view per process); or tdfs4ds.clone_shared_view_time_manager('<DB>.<VIEW>', dry_run=True), then dry_run=False (one clone for the view's readers). |
| time | mixed_time_modes / different_time_drivers | The two ends of a dependency follow different clocks. | Drive both with one TimeManager, or unify_time_managers. |
| time | point_in_time_leak | A TimeManager process reads a dataset built at the current valid time: at a past date it computes from today's values. | build_dataset(..., time_manager=tm). |
| time | fixed_as_of_input / input_other_time_manager | The dataset read is frozen, or follows another manager. | Rebuild it on the process's TimeManager. |
| runs | segments_missing / segment_failed / hollow_run / stuck_running | FilterManager segments not computed or failed at the latest date, runs that wrote nothing, rows stuck at RUNNING. | run(pid) (only missing segments run), fix the cause. |
| refresh | external_time_loop | Check usage (cheap): one execution wrote at least 3 business dates for a process with no TimeManager: a Python loop around run() with FEATURE_STORE_TIME. A schedule (one date per run, across days) and roll_out raise nothing. The detail says whether the view's SQL depends on the date. | Attach a TimeManager, replay with roll_out(..., time_id_start=1, force_compute=True). |
| refresh | external_segment_loop | One execution computed the same business date at least 3 times (COMPLETED) for a process with no FilterManager: the segments come from a loop around run() (view or source changed between calls). | Declare the segments in a FilterManager. |
| refresh | view_rewritten_between_runs | At least 3 stored SQL versions (FS_PROCESS_SQL) that differ only by literals, about one run each: the value changes by REPLACE VIEW; run() only repeats the last value (error). Not checked when versioning is off or absent. | Move the value to a manager. |
| refresh | recursive_query | WITH RECURSIVE / RECURSIVE VIEW in the SQL chain. Warning when the recursion reads only itself (it generates dates or a sequence: a loop inside SQL); info when it walks a table (a hierarchy may be right). | TimeManager, sys_calendar or valid_time_column=. |
| refresh | closed_without_flag | Check closed_entities (reads the storage tables, on by default; assess_workflow(closed_entities=False) skips it): entities of a process whose close_absent_entities is off have only closed validity periods for its features. Something outside the process closed them and a run will not reproduce it. EXPLAIN gates the read (above the limits: not verified). | set_process_options(pid, close_absent_entities=True) if entities really leave; else find what closes them. |
| refresh | validity_gap_without_flag | Same check: flag off and an entity's history has a gap. A run leaves none, so something ended a period outside the process, typically a custom step in a loop around roll_out. The loop itself leaves no trace: this is its mark. | Remove the step; close_absent_entities=True if entities really leave; replay with roll_out in one call. |
| refresh | writes_outside_run | Same check: DBC.QryLogV shows DELETE / UPDATE / INSERT on a process's FS_T_* table with no TDFS4DS query band (removal, relocation and QUERY_BAND=False runs too, hence info: it does not change the verdict). Not verified when the log cannot be read. | No direct writes: see fs-upload, Stay inside the framework. |
| process | sql_drift | The SQL in the database differs from the stored version. | capture_process_sql([pid], dry_run=False) or a run. |
| process | history_mixes_versions | The stored history was computed under several SQL versions. | Replay with roll_out(..., time_id_start=1, force_compute=True) if it must be consistent. |
Per process, report['refresh']['verdicts'][pid] rolls the refresh findings up: refreshable / at risk (a warning) / not refreshable (an error) / not checked, with the reasons. tdfs4ds.process_usage_for(pid, closed=False) gives it for one process (the Feature catalog card calls it). Code only: no language model; a finding never runs its fix.
Rules when explaining the results:
- A dependency between entity columns is observed in the data, not a rule: ask the user to confirm with the business before changing an entity, and say how many entity tuples the evidence covers.
- Nothing is changed by the assessment: every fix is a command the user runs.
- A removal fix is always the script: plan_removal lists the dependents in removal order, write_removal_script
writes a .py that is a dry run unless started with --apply. Ask the user to run the dry run and read it first.
- A primary index or partitioning is recommended per entity, never for one process: it is part of the storage table
name, and a dataset joins all the tables of an entity on the AMP only when they share one index. Changing it keeps the history with plan_relocation (below), or is a
re-registration (remove_feature(..., process_id=), remove_process, upload_features(..., primary_index=...),
then roll_out(..., time_id_start=1, force_compute=True)): registering the view again keeps the recorded index.
- Pruning is judged in two steps. First the data dictionary: does the segment or business-date filter name a
partitioning column of the source? Then the plan, with the manager's value known: DYNAMIC EXPLAIN under
DynamicPlan=SYSTEMX. A static EXPLAIN leaves the subquery value as a parameter and reads all rows even for good
SQL. If the filter matches but the plan still reads every row, the process SQL is the problem.
- Partition elimination needs a filter on one partitioning level, not all of them (seen live: a category filter
alone read 365 of 2,555 partitions, a date alone 7, both a single one).
- Favour scalar filtering for both managers: src.<col> = (SELECT <col> FROM <filter view>), src.<date> <=
(SELECT BUSINESS_DATE FROM <tm view>). The column stays bare; arithmetic goes on the manager's side.
- The admin app has the same checks in Operations → Workflow assessment (entity scan on demand, CSV export), and the Report has a Workflow assessment section.
- Storage-level dataset_rows also reports relocation_reverted: a feature relocated to its own table
(fs-relocate) whose rows an older client (< 0.3.3.30) wrote back to the old table. dataset_reads_stale_table
is repaired by tdfs4ds.rewrite_dataset_tables(dataset) (a dry run; dry_run=False applies it); skew or a wrong primary index by
plan_relocation(process_id=..., table_tag=..., primary_index=[...]) (history kept), not remove / re-register / replay.