Sanity checks¶
A sanity check answers one question about a feature store: is this pipeline built so that it keeps working?
Are the entity keys right, did the processes run in the right order, do the datasets read what exists, and can
run() and roll_out() still refresh every process?
These checks are the workflow assessment:
- Code only. No language model and no agent. They use counts, the data dictionary, the lineage graph, the follow-up table and stored SQL hashes, so the same store gives the same result.
- They change nothing. A finding names the command that fixes it. It never runs that command.
- They say what they could not check. A failed read goes to
report['unverifiable']with its reason. It is never reported as a pass.
Run them¶
One call runs the checks and writes the report:
import tdfs4ds
tdfs4ds.connect(database='MY_DATABASE')
path = tdfs4ds.sanity_check('sanity_report.html') # or 'sanity_report.md'; returns the path
The skill fs-sanity-check generates this code and helps read the report.
The format comes from the file extension, HTML when there is none. Other arguments:
| Argument | Meaning |
|---|---|
fmt |
'html' or 'md', to override the extension |
processes |
Process ids or view names. Default: every process |
data_domains |
Restrict to these data domains |
scope |
'cheap' (default): the cheap checks plus closed_entities, the same checks a migration report runs by default. 'full' adds the entity and dataset scans |
display |
Print the summary and the findings. Default: True |
The report opens with an executive summary: an overall verdict, the main issues, and one row per process in execution
order, with one cell per dimension: ok, the worst severity found, or n/a when the check did not run.
Get the findings as data¶
assess_workflow returns the same content as a dictionary, and write_workflow_report writes it. It also adds CSV.
report = tdfs4ds.assess_workflow(
data_domains=['MY_DOMAIN'], # None = every domain
processes=None, # or a list of process ids / view names
days=90, # follow-up window of the run checks
)
report['counts'] # {'error': n, 'warning': n, 'info': n}
report['health'] # the executive summary
report['unverifiable'] # what could not be checked, and why
for f in report['findings']:
print(f['severity'], f['kind'], f['object'])
print(' ', f['detail'])
print(' fix:', f['fix'])
tdfs4ds.write_workflow_report(report, fmt='csv') # or 'html', 'md'; returns the path
In the app¶
Operations → Workflow assessment, with a data-domain list. The page runs the cheap checks. The scan button runs the checks that read the storage tables, on demand. The report downloads as HTML, Markdown or CSV, and the Report page has a Workflow assessment section.
Which checks read what¶
assess_workflow runs every check by default. Pass checks= to choose, or use entity_scan=False,
dataset_rows=False and closed_entities=False to skip the storage reads.
| Check | Looks at | Cost |
|---|---|---|
integrity |
Catalogs, lineage graph, dataset view definitions; EXPLAIN on processes reading a missing object | Cheap |
network |
EXPLAIN on every process view, dataset view and view of the lineage graph | Cheap, grows with the number of views |
order |
Follow-up table and lineage graph | Cheap |
leakage |
Lineage graph and the way each dataset reads time | Cheap |
segments |
Follow-up table and FilterManager content | Cheap |
sql |
Stored SQL versions against the live SQL | Cheap |
usage |
Follow-up table, stored SQL versions, SQL chain | Cheap |
entity_layout, skew, distribution |
Data dictionary, EXPLAIN of the staging step | Cheap |
entity_scan |
Storage tables: one grouped pass per entity on its largest table | On demand |
dataset_rows |
Storage tables: one grouped pass per table the datasets read | On demand |
closed_entities |
Storage tables, restricted to the process's features, and the query log. EXPLAIN goes first: above 60 seconds or 10 GB of spool the check reports "not verified" and does not run | On demand |
tdfs4ds.workflow_assessment.CHEAP_CHECKS is the list without the three storage reads.
The order and input checks need the persisted lineage graph. If it is empty they are listed as not verified. To fill it:
Can run() and roll_out() still refresh a process?¶
run() and roll_out() refresh a process from what is registered: its view, its managers and its options. What is
done around them is not replayed. If a process was used from outside, for example through a loop in a script or with
entities closed by hand, a refresh computes nothing new or computes something else, and no error is raised.
Each process gets a verdict in report['refresh']['verdicts'][process_id]:
| Verdict | Meaning |
|---|---|
refreshable |
No refresh finding, or information only. Read storage_checked: when it is false, the verdict comes from the run history only |
at risk |
At least one warning. A refresh may not reproduce the data |
not refreshable |
At least one error. A refresh only repeats the last state |
not checked |
The check did not run |
For one process:
usage = tdfs4ds.process_usage_for(process_id, closed=True) # closed=True adds the storage read
usage['verdict'] # 'refreshable', 'at risk', 'not refreshable' or 'not checked'
usage['reasons']
usage['findings'] # kind, label, severity, detail, fix
usage['unverifiable']
The same verdict appears:
- in the executive summary, in the Refresh column;
- on the process card of the Feature catalog page, in the Refresh by run() and roll_out() block, with each finding explained and a button that runs the storage read;
- in the
REFRESHcolumn of the Processes sheet fromtdfs4ds.export_feature_catalog.
Stay inside the framework¶
The loops inside run() (over FilterManager segments) and roll_out() (over dates) belong to the framework and are
fine. Do not build these around them:
| Do not | Why | Do this instead |
|---|---|---|
Loop over dates around run(), setting FEATURE_STORE_TIME |
There is no TimeManager, so roll_out cannot replay the dates |
A TimeManager and one roll_out(process_list, time_manager=tm) |
Loop calling roll_out(time_id_start=i, time_id_end=i) with a custom step between dates |
The next roll_out does not replay the step |
One roll_out over the range, with the step's logic in the process view or an option |
Close validity periods with your own DELETE or UPDATE on FS_T_* |
It leaves gaps that a replay does not reproduce | close_absent_entities=True |
Loop over values around fm.update() and run() |
run() alone computes one segment |
upload_features(..., filtermanager=fm): run() goes through the segments |
REPLACE VIEW with a new literal, or upload_features again, for each date or value |
run() only repeats the last value |
Read the value from a TimeManager or a FilterManager |
| Reload a parameter table between runs | It is a manager the framework does not know | A TimeManager or a FilterManager |
| Generate dates with a recursive query | It is a loop hidden in SQL | A TimeManager, or valid_time_column when the source holds the history |
Write to FS_T_* or to a catalog table |
The values no longer come from the process | run; remove_feature, remove_process, relocate_features |
These are fine: a scheduler calling run once per date, time_id_start and time_id_end to replay a range, and
tm.update() or fm.update() to look at one date or segment.
What the refresh checks can see¶
| Finding | Detected when | Severity | Check |
|---|---|---|---|
external_time_loop |
One execution wrote at least 3 business dates for a process with no TimeManager | warning | usage |
external_segment_loop |
One execution completed the same business date at least 3 times for a process with no FilterManager | warning | usage |
view_rewritten_between_runs |
At least 3 stored SQL versions differ only by literals, with about one run each | error | usage |
recursive_query |
WITH RECURSIVE or RECURSIVE VIEW in the SQL chain. Warning when it only generates dates or a sequence, information when it walks a table |
warning or info | usage |
closed_without_flag |
close_absent_entities is off and entities have only closed validity periods, none open |
warning | closed_entities |
validity_gap_without_flag |
close_absent_entities is off and an entity's history has a gap. A run leaves no gap, so something outside it ended a period |
warning | closed_entities |
writes_outside_run |
The query log shows writes to a process's FS_T_* table with no TDFS4DS query band |
info, does not change the verdict | closed_entities |
Limits:
- A loop whose runs fall in separate executions, such as a new session per date, looks like a schedule. A schedule is good practice and raises nothing, so this loop raises nothing either.
- A loop calling
roll_outone step at a time looks like aroll_out. Only what its custom step did to the storage tables shows, throughvalidity_gap_without_flag,closed_without_flagandwrites_outside_run. That needs theclosed_entitiescheck. writes_outside_runstays information because a removal, a relocation or a run withtdfs4ds.QUERY_BAND=Falsewrites the same way. It also sees only what the query log recorded.
All findings¶
Severity is what the finding reports. Fix is what the finding names; run it yourself after reading it.
Lineage: does each object still have what it reads?¶
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
dataset_reads_removed_process |
A dataset reads the values of a process no longer registered. It returns what that process last wrote, never refreshed | error | Rebuild the dataset, or plan_removal |
dataset_reads_removed_feature |
A dataset reads a feature no longer in the catalog | error | Rebuild the dataset, or plan_removal |
dataset_reads_stale_table |
A dataset reads a feature from a table the catalog no longer uses for it. The view compiles and returns frozen values, then none | error | rewrite_dataset_tables(dataset, dry_run=True) or build_dataset |
dataset_reads_missing_table |
A dataset reads a storage table that no longer exists | error | Restore the table, or rebuild the dataset |
dataset_reads_other_store |
A dataset reads another store's tables, which were not checked | info | Attach that store read-only and assess again |
dataset_feature_no_rows |
Check dataset_rows: a feature has no stored row at the valid time the dataset reads. An INNER dataset returns no row, a FULL OUTER column is all NULL |
error (INNER), warning (FULL OUTER) | run(pid), or rebuild the dataset without the feature |
relocation_reverted |
Check dataset_rows: a relocated feature was written to its old table by an older client, so its history is split |
error | Run the relocation again: plan_relocation, then relocate_features |
feature_without_process |
A registered feature that no process computes any more | warning | Register a process computing it, or plan_removal |
process_view_missing, dataset_view_missing |
A catalog row whose view is gone | error | Restore the view, or plan_removal |
process_reads_missing_object, process_view_broken |
A process view reads an object that no longer exists, or no longer compiles | error | Restore the object, or plan_removal |
process_reads_inaccessible_object |
A process reads an object this user cannot see, and its EXPLAIN is refused | warning | The GRANT the finding names |
process_reads_unregistered_dataset |
A process view reads a dataset view no longer in the catalog | warning | restore_dataset_catalog(dry_run=True), or rewrite the view |
lineage_edge_to_unknown |
The graph links a dataset to a view that is not a registered process | info | rebuild_lineage_graph(objects=[...], check=False) |
view_does_not_compile |
Check network: EXPLAIN fails. Only the root failure is reported, with what it stops |
error | Fix or restore the view |
view_not_verifiable |
EXPLAIN is refused for lack of a right. The view may be fine; nothing below it was checked | warning | The GRANT the finding names |
lineage_stops_no_access |
The lineage stops at a view whose definition this user cannot read | warning | The GRANT named, then rebuild_lineage_graph(objects=[...], check=True) |
lineage_not_recorded |
The view reads objects the graph lacks | warning | rebuild_lineage_graph(objects=[...], check=True) |
lineage_stops_unreadable |
SHOW VIEW fails on a real object. A SQL word the graph stored as a name, such as CAST, is not reported |
warning | Read the message in the finding |
lineage_isolated |
A process or dataset with no lineage link: nothing is known of what it reads or what reads it | warning | rebuild_lineage_graph(objects=[...], check=True) |
lineage_split |
The lineage is several separate networks. Independent pipelines are expected | info | Check that no process is missing a link |
process_not_read |
No dataset or process reads this process | info | Build a dataset on it, or plan_removal |
detached_branch |
Views and tables that no registered process or dataset reaches, usually left by a removal | info | Drop them, then rebuild the graph |
views_not_compiled |
Views over the compilation limit were not compiled | info | Run the check on a smaller scope |
The report's Lineage section always says what it checked, also when it found nothing. Removal fixes go through a script
that is a dry run by default: tdfs4ds.plan_removal, then tdfs4ds.write_removal_script.
Entity keys¶
A dependency between entity columns is observed in the data, not a rule. Confirm it with the business before you change an entity.
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
redundant_key_column |
Check entity_scan: over the whole history, the other key columns are unique without this one. A lookup by the real key cannot use the primary index |
warning, info under 100 entity tuples | Register the processes with the smaller entity_id; keep the column as a feature |
key_column_changes_over_time |
Check entity_scan: determined by the other columns now, but it changed over time, and each change started a new entity |
warning, info under 100 entity tuples | Remove it from entity_id and store it as a feature |
entity_key_superset |
Two entity keys of one domain, one containing the other: features of one entity may be split | info | Run the entity scan, then decide |
Order and time¶
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
ran_before_upstream |
At a business date, the process started before its upstream finished | warning | generate_execution_script, then re-run with force_compute=True |
upstream_recomputed_after |
The upstream was recomputed after the process ran: the process is stale | warning | roll_out over those dates with force_compute=True |
completed_on_failed_upstream |
The upstream failed or wrote nothing, and the process still completed | error | Re-run the upstream, then the process with force_compute=True; use check_upstream=True |
upstream_missing_at_date, ahead_of_upstream |
On one timeline, the process computed dates its upstream has not | warning | Roll the upstream out first |
mixed_time_modes |
One end of a dependency follows a TimeManager, the other real time or another mode | warning or info | Drive both with one TimeManager |
different_time_drivers |
The two ends follow different managers | info | unify_time_managers([...], dry_run=True) if they must stay aligned |
process_not_on_domain_clock |
The data domain has a clock and this process reads another calendar or none | warning | align_domain_time_managers(domain, process_ids=[pid], dry_run=True) |
processes_share_time_filtered_view |
Processes read the clock through one shared view, so none can have its own cursor | warning | Move the filter, or clone_shared_view_time_manager(view, dry_run=True) |
Inputs in time¶
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
point_in_time_leak |
A TimeManager process reads a dataset at the current valid time: at a past date, it computes from today's values | error | build_dataset(..., time_manager=tm) |
fixed_as_of_input |
The dataset read is frozen at one date | warning | Rebuild it on the process's TimeManager |
input_other_time_manager |
The dataset read follows another manager | warning | Rebuild it on the process's TimeManager |
Runs¶
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
segments_missing |
FilterManager segments not computed at the latest date | warning | run(pid): only the missing segments run |
segment_failed |
A segment failed at the latest date | error | Fix the cause, then run(pid) |
hollow_run |
A run wrote no rows | info | Check the source and the filter |
stuck_running |
A follow-up row still reads RUNNING after 12 hours (stuck_hours=) |
warning | Check whether the session died, then re-run |
Process SQL¶
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
sql_drift |
The SQL in the database differs from the stored version | warning | capture_process_sql([pid], dry_run=False), or a run |
history_mixes_versions |
The stored history was computed under several SQL versions | info | If it must be consistent, roll_out(..., time_id_start=1, force_compute=True) |
Storage and pruning¶
A primary index or a partitioning is recommended per entity, never for one process. A dataset joins the tables of an entity on the AMP only when they share one index. To change one, see Relocating features.
| Finding | Meaning | Severity | Fix |
|---|---|---|---|
storage_skew |
A storage table concentrated on a few AMPs | warning | Check the entity columns |
entity_column_type_mismatch |
An entity column typed differently across tables: joins convert and rows leave their AMP | warning | Cast in the process views, then register again |
entity_pi_inconsistent |
The tables of one entity use different primary indexes: datasets joining them redistribute | warning | One primary_index= for every process of the entity |
pi_not_aligned_with_source |
The largest source is hashed differently from the storage tables. A warning when EXPLAIN shows the aligned index would keep rows local | warning or info | Same index for the whole entity |
partition_not_aligned_with_source |
The largest source is partitioned on an entity column; the storage tables are not | info | partitioning= |
segments_rescan_source |
The FilterManager segments do not follow the source's partitioning: each segment reads all its partitions. Whatever the size: on a small source the warning says it does no harm today, but it will if the table grows | warning | Segment on the partitioning column, if the business logic allows it |
segment_filter_defeats_pruning |
The filter names a partitioning column but, even with the value known, the plan reads all rows | warning | A scalar filter on the bare column |
time_filter_by_join, segment_filter_by_join |
The view reads its TimeManager or FilterManager through a join: explicit, a comma list, or a derived table. The query may not work as intended: a manager holding two rows multiplies the view's rows, where a scalar subquery fails | warning | A scalar filter, e.g. WHERE src.d <= (SELECT BUSINESS_DATE FROM tm). Exception: views scored on the ACC need the join |
time_filter_not_scalar, segment_filter_not_scalar |
The view reads the manager with IN or EXISTS, or through an intermediate view selecting from it |
warning | A scalar filter in the view that uses the value |
segment_filter_off_hierarchy |
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 (measured, 365 days x 5 regions: 366 partitions on the region alone, 5 on the date, 1 on both). A TimeManager's scalar filter on the level above counts. On a small source the warning says 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 to production | warning | Add the higher level to the FilterManager's columns, or filter it with the TimeManager, if the business logic allows it |
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 | info | Compare it with the partitioning column, if that column carries the same date |
time_filter_defeats_pruning |
A scalar business-date filter on the partitioning column still prunes nothing | warning | Keep the column bare; put arithmetic inside the subquery |
fs_partition_not_on_filter |
Segments on entity columns, but the storage tables are not partitioned on them | info | partitioning= |
Before a migration¶
plan_migration runs these checks first, on the source store and only on the processes it would promote. A process
that cannot be refreshed in the lab will not be refreshable in production. The findings are the first section of the
migration report.
plan = tdfs4ds.plan_migration(
['<process, dataset or feature>'],
source='LAB_DATABASE',
sanity='cheap', # the default. 'full' adds the entity and dataset scans; False skips and says so
)
plan['sanity']['findings']
plan['sanity']['verdicts'] # refreshable, at risk, not refreshable, per process
print(tdfs4ds.render_migration_report(plan))
'cheap'is the cheap checks plusclosed_entities, because a custom step aroundroll_outshows nowhere else. Its reads are EXPLAIN-gated.- A finding never blocks
migrate_objects. Approvals are about conflicts. The report flags the processes to look at. - In the app: the Migration page, field Sanity check of the processes.
To confirm the rights after the GRANTs were applied, run this as the target user. It reads only, and each refusal carries the GRANT that lifts it:
With several stores attached¶
When the same object exists in several attached stores, the first store in the list wins. To list these collisions:
conflicts = tdfs4ds.store_conflicts() # KIND, NAME, WINNER_STORE, OTHER_STORES, DIFFERS, DETAIL...
conflicts.attrs['stores'] # the winning order
conflicts.attrs['unverified'] # the reads that failed
The kinds are feature, process_view, dataset, documentation and lineage. With one store, nothing is read and
the result is empty. The Report page shows the same list.
See also¶
- Inspect & monitor: the catalogs, the follow-up table, catalog and storage consistency.
- Failure handling: what happens when a run fails.
- TimeManager & roll_out and FilterManager: how to drive dates and segments.
- Persisted lineage graph: what the order and input checks read.