Skip to content

tdfs4ds.workflow_assessment

tdfs4ds.workflow_assessment

Workflow assessment: is the pipeline well built? (0.3.3.25)

store_consistency answers "do the catalogs and the storage line up?". This module answers a different question: is the workflow well implemented?

  • Entity keys (area entity). Users often put every id column they know into entity_id. A column the others determine splits nothing, yet it widens the primary index of every storage table, so a lookup by the real key cannot use it, and an attribute that changes over time starts a new entity at each change. The scan counts distinct key tuples in the storage tables, over the whole history and now, with each column left out in turn.
  • Order and synchronisation (area time). Did every process run after the processes it reads, at each business date? Do the two ends of a dependency follow the same TimeManager? Is a TimeManager-driven process reading a dataset that does not move with its valid time (point-in-time leakage)?
  • Runs (area runs). FilterManager segments missing or failed at the latest date, hollow runs (COMPLETED,0 rows), rows stuck at RUNNING.
  • Process SQL (area process). Live SQL that differs from the stored version, and histories computed under several versions.
  • Storage (area storage). Primary-index skew, entity columns typed differently across tables, entity keys contained in other ones.

Three layers, like the other report sections: :func:collect_workflow_inputs is the only I/O, :func:build_workflow_model is pure, :func:render_workflow_html returns HTML. :func:assess_workflow runs the first two.

Rules:

  • No LLM. Every check is a count, a dictionary read, a graph walk or a hash comparison; every text is a fixed template. A test guards the imports.
  • Every finding names its fix and nothing here runs it.
  • A check that cannot run is listed in unverifiable with its reason; it is never reported as passing.
  • A dependency between entity columns is observed in the data, never a rule: the finding says so and asks for the business to confirm.
  • Primary store only.

AREAS module-attribute

AREAS = ['lineage', 'entity', 'time', 'runs', 'refresh', 'process', 'storage']

AREA_TITLES module-attribute

AREA_TITLES = {'lineage': 'Lineage integrity', 'entity': 'Entity keys', 'time': 'Order and synchronisation', 'runs': 'Runs and segments', 'refresh': 'Refresh by run() and roll_out()', 'process': 'Process SQL', 'storage': 'Storage layout'}

WORKFLOW_KIND_LABELS module-attribute

WORKFLOW_KIND_LABELS = {'redundant_key_column': 'Entity column determined by the other key columns', 'key_column_changes_over_time': 'Entity column that changes over time', 'entity_key_superset': 'Entity key containing another entity key', 'entity_column_type_mismatch': 'Entity column typed differently across tables', 'storage_skew': 'Storage table skewed across AMPs', 'entity_pi_inconsistent': 'Storage tables of one entity with different primary indexes', 'pi_not_aligned_with_source': 'Primary index not aligned with the largest source', 'partition_not_aligned_with_source': 'Partitioning not aligned with the largest source', 'segments_rescan_source': 'FilterManager segments each reading the whole source', 'segment_filter_defeats_pruning': 'Segment filter on the partitioning column that the SQL keeps from pruning', 'time_filter_by_join': 'TimeManager read through a join instead of a scalar filter', 'time_filter_not_scalar': 'TimeManager read in another form than a scalar filter', 'segment_filter_by_join': 'FilterManager read through a join instead of a scalar filter', 'segment_filter_not_scalar': 'FilterManager read in another form than a scalar filter', 'segment_filter_off_hierarchy': "FilterManager skipping a higher level of the source's partitioning", 'time_filter_not_on_partitioning': 'Business date compared with a column the source is not partitioned on', 'time_filter_defeats_pruning': 'Business-date filter on the partitioning column that the SQL keeps from pruning', 'partitioned_source_read_whole': 'Partitioned source read whole by the plan', 'fs_partition_not_on_filter': 'Storage tables not partitioned on the segmentation columns', 'date_computed_before_earlier_date': 'Business date computed before an earlier date of the same process', 'dbc_nearly_full': 'Database DBC nearly full', 'ran_before_upstream': 'Process started before its upstream had finished', 'upstream_recomputed_after': 'Upstream recomputed after the process ran', 'upstream_missing_at_date': "Upstream not computed at the process's business date", 'completed_on_failed_upstream': 'Process completed on a failed or empty upstream', 'ahead_of_upstream': 'Process ahead of its upstream in business time', 'mixed_time_modes': 'Dependency between real time and a TimeManager', 'different_time_drivers': 'Dependency between two independent TimeManagers', 'process_not_on_domain_clock': 'Process of a data domain not on the domain clock', 'processes_share_time_filtered_view': 'Processes sharing the domain clock through a view', 'point_in_time_leak': 'TimeManager process reading a current dataset', 'fixed_as_of_input': 'TimeManager process reading a fixed-date dataset', 'input_other_time_manager': 'Process reading a dataset on another TimeManager', 'segments_missing': 'FilterManager segments not computed at the latest date', 'segment_failed': 'FilterManager segment failed at the latest date', 'hollow_run': 'Run that wrote no rows', 'stuck_running': 'Run still marked RUNNING', 'interrupted_run': 'Run interrupted without recording an outcome', 'sql_drift': 'Live SQL different from the stored version', 'history_mixes_versions': 'History computed under several SQL versions', 'dataset_reads_removed_process': 'Dataset reading the values of a removed process', 'dataset_reads_removed_feature': 'Dataset reading a feature removed from the catalog', 'dataset_reads_stale_table': 'Dataset reading a storage table the catalog no longer uses for the feature', 'dataset_reads_missing_table': 'Dataset reading a storage table that no longer exists', 'dataset_feature_no_rows': 'Dataset feature with no stored rows', 'relocation_reverted': 'Relocated feature registered or written in its old table again (older client)', 'feature_without_process': 'Feature no process computes any more', 'process_view_missing': 'Process whose view no longer exists', 'dataset_view_missing': 'Dataset whose view no longer exists', 'process_reads_missing_object': 'Process view reading an object that no longer exists', 'process_view_broken': 'Process view that no longer compiles', 'process_reads_unregistered_dataset': 'Process view reading a dataset no longer registered', 'lineage_edge_to_unknown': 'Lineage edge to a view that is no registered process', 'dataset_reads_other_store': 'Dataset reading another feature store (not checked from this one)', 'view_does_not_compile': 'View that does not compile (EXPLAIN fails)', 'view_not_verifiable': 'View this user may not EXPLAIN (missing right): not verified', 'process_reads_inaccessible_object': 'Process view reading an object this user has no right on', 'lineage_stops_no_access': 'Lineage stopping at a view whose definition this user cannot read', 'lineage_not_recorded': 'View whose inputs the lineage graph does not record', 'lineage_stops_unreadable': 'Lineage stopping at a view SHOW VIEW refuses', 'views_not_compiled': 'Views not compiled (over the limit)', 'lineage_split': 'Lineage made of separate networks', 'lineage_isolated': 'Process or dataset with no lineage link', 'process_not_read': 'Process nobody reads (dead end)', 'detached_branch': 'Lineage branch no process or dataset reads (dead branch)', None: KIND_LABELS}

LINEAGE_KINDS module-attribute

LINEAGE_KINDS = ('dataset_reads_removed_process', 'dataset_reads_removed_feature', 'feature_without_process', 'process_view_missing', 'dataset_view_missing', 'process_reads_missing_object', 'process_view_broken', 'process_reads_unregistered_dataset', 'lineage_edge_to_unknown', 'dataset_reads_stale_table', 'dataset_reads_missing_table', 'process_reads_inaccessible_object')

STORAGE_LINEAGE_KINDS module-attribute

STORAGE_LINEAGE_KINDS = ('dataset_feature_no_rows', 'relocation_reverted')

CHECKS module-attribute

CHECKS = ('entity_scan', 'entity_layout', 'skew', 'distribution', 'order', 'leakage', 'segments', 'sql', 'integrity', 'network', 'dataset_rows', 'usage', 'closed_entities', 'dbc_space')

CHEAP_CHECKS module-attribute

CHEAP_CHECKS = tuple(c for c in CHECKS if c not in ('entity_scan', 'dataset_rows', 'closed_entities'))

_FAIL module-attribute

_FAIL = 'FAIL'

_RUNNING module-attribute

_RUNNING = 'RUNNING'

_FU_COLUMNS module-attribute

_FU_COLUMNS = ['pid', 'run_id', 'start', 'end', 'status', 'vdate', 'dkey', 'seg']

PROBE_TABLE module-attribute

PROBE_TABLE = 'TDFS4DS_WA_PROBE'

_MANAGER_JOIN_RISK module-attribute

_MANAGER_JOIN_RISK = "through a join (explicit, a comma list, or a derived table). The query may not work as intended: its value is a join value rather than a constant the optimizer substitutes, and a manager that ever holds two rows multiplies the view's rows silently, where a scalar subquery fails (Error 3669)."

_MANAGER_OTHER_RISK module-attribute

_MANAGER_OTHER_RISK = 'in another form than a scalar filter (IN, EXISTS, or an intermediate view selecting from it). The query may not work as intended, and what the optimizer does with the value could not be told from the SQL.'

_SMALL_SOURCE_NOTE module-attribute

_SMALL_SOURCE_NOTE = ' At this size it does no harm today. It will if the table grows, as it may when a process built on a small lab table is migrated to production.'

SCALAR_OF_COLUMN_TYPE module-attribute

SCALAR_OF_COLUMN_TYPE = "of the column's type: for a TIMESTAMP(0) column (SELECT CAST(SUBSTR(CAST(BUSINESS_DATE AS VARCHAR(40)), 1, 19) AS TIMESTAMP(0)) FROM <time manager view>), for a DATE column (SELECT CAST(BUSINESS_DATE AS DATE) FROM <time manager view>); a direct CAST(BUSINESS_DATE AS TIMESTAMP(0)) is Error 7454 when the manager stores TIMESTAMP(6), as one loaded from a pandas datetime does"

_ACC_EXCEPTION module-attribute

_ACC_EXCEPTION = 'exception: a view scored on the Analytical Compute Cluster (tdstone2 / Apply) needs the JOIN (a scalar subquery there is Error 6881), so leave that one as it is'

_PID_RE module-attribute

_PID_RE = None

DIMENSIONS module-attribute

DIMENSIONS = [('lineage', 'Lineage', ('integrity', 'network')), ('entity', 'Entity keys', ('entity_scan',)), ('order', 'Order and time', ('order',)), ('inputs', 'Inputs in time', ('leakage',)), ('runs', 'Runs', ('segments',)), ('sql', 'Process SQL', ('sql',)), ('refresh', 'Refresh', ('usage',)), ('storage', 'Storage and pruning', ('distribution', 'skew'))]

_LEAKAGE_KINDS module-attribute

_LEAKAGE_KINDS = {'point_in_time_leak', 'fixed_as_of_input', 'input_other_time_manager'}

_CHECK_DIMENSION module-attribute

_CHECK_DIMENSION = {'integrity': 'lineage', 'network': 'lineage', 'dataset_rows': 'lineage', 'entity_scan': 'entity', 'order': 'order', 'leakage': 'inputs', 'segments': 'runs', 'usage': 'refresh', 'closed_entities': 'refresh', 'runs': 'runs', 'sql': 'sql', 'distribution': 'storage', 'storage': 'storage'}

_SEVERITY_RANK module-attribute

_SEVERITY_RANK = {'error': 3, 'warning': 2, 'info': 1}

_EXEC_CSS module-attribute

_EXEC_CSS = '<style>\n.twa-exec{margin:4px 0 18px}\n.twa-exec h3{margin:0 0 8px;font-size:1.05rem}\n.twa-cards{display:flex;flex-wrap:wrap;gap:10px;margin:6px 0 10px}\n.twa-card{border:1px solid rgba(127,127,127,.35);border-left:4px solid #FF5F00;border-radius:8px;padding:6px 12px;min-width:110px}\n.twa-card b{display:block;font-size:1.35rem;line-height:1.2}\n.twa-card span{font-size:.78rem;opacity:.8}\n.twa-card.e{border-left-color:#C62828}.twa-card.w{border-left-color:#EF6C00}\n.twa-card.i{border-left-color:#2F6E9E}.twa-card.o{border-left-color:#2E7D32}\n.twa-verdict{margin:4px 0 8px}\n.twa-top{margin:0 0 12px 18px;padding:0}\n.twa-gridwrap{overflow-x:auto;max-width:100%}\ntable.twa-grid{border-collapse:separate;border-spacing:3px;font-size:.82rem}\ntable.twa-grid th{font-weight:600;text-align:left;padding:2px 6px;white-space:nowrap}\ntable.twa-grid th.d{text-align:center;max-width:90px;white-space:normal}\ntable.twa-grid td.p{padding:2px 8px;white-space:nowrap;max-width:320px;overflow:hidden;text-overflow:ellipsis}\ntable.twa-grid tr.wave td{padding:8px 4px 2px;font-weight:600;color:#FF5F00;border-bottom:1px solid rgba(127,127,127,.3)}\ntd.twa-c{width:74px;text-align:center;color:#fff;border-radius:4px;font-weight:700}\ntd.twa-error{background:#C62828}td.twa-warning{background:#EF6C00}td.twa-info{background:#2F6E9E}\ntd.twa-ok{background:#2E7D32}td.twa-na{background:rgba(127,127,127,.35);color:inherit;font-weight:400}\n.twa-legend{font-size:.78rem;opacity:.85;margin-top:6px}\n.twa-legend i{display:inline-block;width:12px;height:12px;border-radius:3px;vertical-align:middle;margin:0 4px 0 10px}\n</style>'

_CELL_MARK module-attribute

_CELL_MARK = {'error': '&#10006;', 'warning': '&#9650;', 'info': '&#9679;', 'ok': '&#10003;', 'n/a': '&ndash;'}

_CELL_WORD module-attribute

_CELL_WORD = {'error': 'error', 'warning': 'warning', 'info': 'info', 'ok': 'nothing to report', 'n/a': 'not checked'}

_MD_MARK module-attribute

_MD_MARK = {'error': '✖ error', 'warning': '▲ warning', 'info': '● info', 'ok': '✓', 'n/a': '–'}

logger_safe

logger_safe(level, message, *args, **kwargs)

Wrapper around the global logger that only emits logs when tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.

qualified

qualified(database, object_name, force=False)

Build db.obj with each part quoted only as needed.

qualified('TDB', 'FS_X') == 'TDB.FS_X' (unchanged for ordinary names); qualified('SVC@CORP', 'FS_X') == '"SVC@CORP".FS_X'. An empty/None database yields the bare object name, so unqualified callers keep working.

force=True quotes both parts unconditionally — only for the sites that have always emitted quotes and whose exact text is already persisted (dataset view DDL, returned volatile-table names).

sql_literal

sql_literal(value)

Escape value for use inside a single-quoted SQL string literal.

For the DBC probes and catalog predicates that compare a name as data (WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.

_finding

_finding(area, kind, obj, detail, severity, fix='', pids=None, **ref)

A finding. pids: the processes it concerns (the executive summary places it on their rows); ref: entity=(DOMAIN, KEY) or table='DB.T' for the findings that are mapped to processes later, in the model.

_tag

_tag(findings: list, pids) -> None

Place findings (a slice just produced) on the processes pids, unless a finding already names its own.

_u

_u(v) -> str

_clean

_clean(v) -> Optional[str]

_ts

_ts(v)

A UTC pandas Timestamp, or None.

_day

_day(t) -> str

_fmt_dates

_fmt_dates(dates, limit=5) -> str

_short

_short(view) -> str

prepare_followup

prepare_followup(followup) -> pd.DataFrame

FS_FOLLOW_UP rows -> pid, run_id, start, end, status, vdate, dkey, seg.

vdate is the business date (VALIDTIME_DATE, NaT for a real-time run), dkey its day as text ('' in real time), seg the applied filter ('' when unsegmented). Pure.

_is_ok

_is_ok(s) -> bool

_is_hollow

_is_hollow(s) -> bool

_is_fail

_is_fail(s) -> bool

date_states

date_states(fu: DataFrame) -> Dict[tuple, dict]

{(pid, dkey): state} for the TimeManager rows (dkey != '').

A state describes the last computation at that business date, per segment: ok_start / ok_end (first start and last end of the latest COMPLETED row of each segment), failed / hollow (a segment whose latest row failed / wrote nothing, with its start), completed, vdate. Pure.

time_groups

time_groups(time_model: Optional[dict]) -> Dict[str, Any]

{"driver": {pid: manager}, "group": {manager: group id}} from the time-driver model. A manager outside any synchronised / clone group is its own group. Pure.

_same_group

_same_group(tg, a, b) -> Optional[bool]

True / False when both processes have a known driver, else None.

direct_edges

direct_edges(edges) -> set

The process dependencies without the transitive ones (q -> p). A cycle keeps every edge. Pure.

process_calendars

process_calendars(time_model: Optional[dict]) -> Dict[str, List[str]]

{pid: ['YYYY-MM-DD', ...]}: the dates of the manager driving each process, in TIME_ID order, when they were read (0.3.7.12). Pure.

domain_clocked

domain_clocked(time_model: Optional[dict]) -> Dict[str, str]

{pid: data domain} of the processes on their domain's clock (the clock or a soft clone of it). For them a replay is roll_out(data_domain=...), which keeps the processes downstream in step; a process on another manager is replayed alone (0.3.7.13). Pure.

_usable_calendars

_usable_calendars(fu: DataFrame, calendars: Optional[Dict[str, List[str]]]) -> Dict[str, List[str]]

The calendars that hold at least one of their process's follow-up dates. A calendar holding none cannot be the one the process ran on (or was read in another format): it is ignored, so the checks fall back to every date rather than hiding all of them. Pure.

date_order_findings

date_order_findings(fu: DataFrame, names: Optional[dict] = None, calendars: Optional[Dict[str, List[str]]] = None, history_from_data: Optional[set] = None, domains: Optional[Dict[str, str]] = None) -> List[dict]

A business date whose latest run started before a run at an earlier date of the same process ended. Built forward, each date runs after the one before; otherwise the later date did not see the earlier ones, and a run also writes from its date onward. Pure.

calendars (0.3.7.12): {pid: dates of its manager}. Only those dates are compared: a run at another date (run(data_domain=...) at the database clock, run(..., at=...)) is not part of the history a roll_out builds, and no roll_out recomputes it. A process without a known calendar keeps every date. history_from_data: processes with valid_time_column, whose values take their valid time from the data, not from the run's date.

dbc_space_findings

dbc_space_findings(space, full_share: float = 0.9) -> List[dict]

space: (vproc, current perm, max perm) of database DBC. DBC fills unevenly and refuses a write as soon as one AMP is full, so the fullest AMP decides. Pure.

domain_clock_findings

domain_clock_findings(time_model: Optional[dict], names: Optional[dict] = None) -> List[dict]

A process of a data domain that has a clock (0.3.6.0) but reads no manager on its dates (or another one): run(data_domain=...) / roll_out(data_domain=...) cannot keep it in step. Pure.

order_findings

order_findings(edges, fu: DataFrame, tg: dict, names: Optional[dict] = None) -> List[dict]

Findings for each dependency q -> p (q upstream). Pure.

TimeManager rows are compared business date by business date; real-time rows by overlap of the runs only (two real-time processes on different cadences are normal).

input_datasets

input_datasets(G, node, process_nodes: set) -> List[str]

Dataset nodes a process view reads, walking through plain views and stopping at datasets and at other processes' views. Pure.

leakage_findings

leakage_findings(G, processes, tg, dataset_modes, tm_pids=(), names=None) -> tuple

(findings, unverifiable). A process counts as TimeManager-driven when its view reads a manager or its runs carry a business date. Pure.

segment_findings

segment_findings(fu: DataFrame, expected: Dict[str, int], names=None, now=None, stuck_hours: Optional[float] = None, stuck_factor: float = 10, live=None, calendars=None, domains=None) -> List[dict]

Missing / failed segments and hollow runs at each process's latest date, rows left at RUNNING at any date. expected: {pid: number of FilterManager rows}.

RUNNING rows (0.3.7.2): interrupted_run (info) when a later row exists for the same process, business date and segment; stuck_running (warning) for a row with nothing after it older than max(stuck_hours or 1 h, stuck_factor x the longest COMPLETED run of the process). live: {(run_id, process_id)} carried by the database's sessions (None = not read): a row no session carries is reported as interrupted_run whatever its age. Pure.

_at

_at(t) -> str

_rollout_resume

_rollout_resume(fu, pid, run_id, dkey, calendars=None, domains=None)

(call, reason) resuming a roll-out from dkey, or None (0.3.7.12). Proposed when the lost row belongs to a roll-out (rows at several business dates under its RUN_ID), or when its date is a date of the process's calendar other than the last (a roll-out cut on its first date leaves a single date under a fresh RUN_ID). run(pid) would compute one date, at the cursor, and leave the later dates and the processes downstream. Pure.

_open_run_findings

_open_run_findings(fu, names, now, stuck_hours, stuck_factor, live, calendars=None, domains=None) -> List[dict]

interrupted_run / stuck_running findings (see :func:segment_findings). Pure.

_removal_call

_removal_call(objects) -> str

integrity_findings

integrity_findings(gaps, scope_pids=None, scope_domains=None) -> List[dict]

Findings from :func:tdfs4ds.dependencies.lineage_gaps. Each names its fix; a gap that leaves a dead branch also carries removal, the objects to pass to :func:tdfs4ds.plan_removal. With a scope (processes or data domains), only the gaps touching it are kept. Pure.

dataset_rows_findings

dataset_rows_findings(rows, scope_pids=None, scope_domains=None) -> List[dict]

dataset_feature_no_rows findings from the storage-level check. rows: {"reads": dependencies.dataset_feature_reads(H), "scan": scan_storage_orphans( by_version=True), "completed": {process id: COMPLETED runs} or None}.

A feature read has no rows when the table holds none for its (FEATURE_ID, FEATURE_VERSION) at the valid time the dataset reads (now for a current dataset, any time otherwise). An INNER dataset then returns no row at all (error); a FULL OUTER one reads NULL for the column (warning). The follow-up tells a process that never completed from one whose rows are gone. A table that could not be scanned is skipped (the caller reports it). Pure.

relocation_reverted_findings

relocation_reverted_findings(strays, scope_pids=None, scope_domains=None) -> List[dict]

relocation_reverted findings from the storage-level check. strays: :func:tdfs4ds.feature_store.relocation.read_relocation_strays.

A relocated feature has a placement tag. A client older than 0.3.3.30 does not know it: when it registers the feature again (a type change, or removed and registered anew) it names the untagged table (the catalog row follows) and writes its values there, so the history is split over two tables and the datasets read either. Pure.

network_nodes

network_nodes(processes, datasets)

({node: {"pid", "label"}}, {node: {"label"}}) of the registered process and dataset views, keyed like the persisted lineage graph and labelled like :func:tdfs4ds.dependencies.build_dependency_graph. Pure.

network_scope_findings

network_scope_findings(network, gaps=None, scope_pids=None) -> List[dict]

:func:tdfs4ds.lineage.network_health.network_findings, without the objects the gap check already reported. With a process scope, the findings about other processes are dropped; those about the whole network stay. Pure.

sql_findings

sql_findings(versions: Dict[str, list], drift: Dict[str, dict], fu: DataFrame, names=None) -> List[dict]

versions: {pid: [{"PROCESS_VERSION", "VALID_FROM", "VALID_TO"}]}; drift: {pid: {"since", "changed_steps"}}. Pure.

entity_subsets

entity_subsets(cols) -> List[tuple]

[("ALL", cols), ("-C", cols without C), ...].

entity_count_sql

entity_count_sql(database, table, cols) -> str

Distinct entity tuples of a storage table, for the key and the key minus each column, over the whole history (H:) and now (C:). One request.

The temporal qualifier sits inside each derived table (a derived table refuses CURRENT, and a UNION branch refuses a leading qualifier: Error 9345); the label is CAST because the first branch types the column.

parse_counts

parse_counts(rows) -> Dict[str, Dict[str, int]]

redundancy

redundancy(counts, cols) -> tuple

(determined over the whole history, determined now only). Pure.

reduce_entity_key

reduce_entity_key(run_sql: Callable[[str], list], database, table, cols) -> dict

Greedy reduction: drop a column the others determine over the whole history, re-count, until none is left (at most one round per column). run_sql returns the rows of a statement. Pure apart from run_sql.

entity_scan_findings

entity_scan_findings(results, pi=None) -> List[dict]

Findings from :func:reduce_entity_key results. pi: {(DB, TABLE): [columns]}. Pure.

_pairs_with_results

_pairs_with_results(findings, results)

Each entity-scan finding with the scan result it came from (same object).

entity_superset_findings

entity_superset_findings(features) -> List[dict]

Two entity keys of one domain where one contains the other. Pure.

type_family

type_family(column_type, char_type=None, scale=None) -> str

The family that decides whether two columns join without conversion.

type_mismatch_findings

type_mismatch_findings(columns, entity_cols) -> List[dict]

columns: [(db, table, column, family)]; entity_cols: {(DB, TABLE): {COL}}. Pure.

skew_findings

skew_findings(sizes, threshold: float = 0.25, min_mb: float = 100) -> List[dict]

sizes: {(db, table): [CurrentPerm per AMP]}. Skew = 1 - avg / max. Pure.

_cols_of

_cols_of(text) -> List[str]

source_tables

source_tables(G, node, stop_nodes: set) -> List[str]

Tables a process view reads: walk through plain views, stop at datasets, at other processes' views and at manager / FS objects. Pure.

aligned_pi

aligned_pi(entity_cols, source_node, source_pi, origins) -> Optional[List[str]]

The entity columns that carry the source's primary-index columns, in the source's PI order; None unless every PI column maps. origins: {entity col: {"node", "column"}} from :func:column_lineage. Pure.

_flat

_flat(text) -> str

_steps

_steps(text) -> List[str]

explain_staging_distribution

explain_staging_distribution(text, probe: str = PROBE_TABLE) -> Optional[str]

How the rows reach the probe table of a staging CTAS EXPLAIN: "local" (the spool feeding it is built locally), "redistributed" (by hash code), "duplicated", or None when the text does not say. Read from the steps, never counted. Pure.

table_aliases

table_aliases(texts: Iterable[str], source_node) -> List[str]

Correlation names the view SQL gives source_node: EXPLAIN names a table by them (DB_SOURCE.A in view ..., seen live), not by its name. Pure.

source_read_access

source_read_access(text, source_node, aliases=()) -> Optional[str]

How an EXPLAIN reads source_node ('DB.TABLE'): "partitions" (partition elimination, incl. a single partition), "all_rows" (no elimination), or None when no step names it. aliases: correlation names of the table (see :func:table_aliases). The worst step wins. Pure.

cast_partition_condition

cast_partition_condition(text, source_node, aliases, columns) -> Optional[str]

The partitioning column of source_node that a plan step compares, cast to a TIMESTAMP ... WITH TIME ZONE, with a parameter (CAST((DB.h in view V.TD_TIMECODE) AS TIMESTAMP(6) WITH TIME ZONE) < :%SSQ27, measured on a TIMESTAMP(0) column compared with a TIMESTAMP(6) WITH TIME ZONE scalar), else None. The column is cast, not the scalar, so no partition can be eliminated: a fact of the SQL, which a static plan shows as well as a dynamic one. Pure.

partition_columns

partition_columns(constraint_text, columns) -> List[str]

Columns of a table named in its partitioning expression (FEATURE_ID and the valid-time columns left out). Pure.

partition_levels

partition_levels(constraint_text, columns) -> List[List[str]]

The columns of each partitioning level, in level order (DBC keeps the levels in order: CHECK (/*02*/ RANGE_N(d ...) IS NOT NULL AND CASE_N(region ...) IS NOT NULL ), read live). Literals are removed first: region = 'N' must not name a column N. Pure.

_enclosing_paren

_enclosing_paren(flat: str, pos: int) -> int

Index of the parenthesis enclosing pos, or -1 at the top level.

_managers_in_use

_managers_in_use(domain_clocks: Optional[dict], dataset_modes: Optional[dict]) -> set

The manager views in use though the lineage graph shows no reader: the domain clocks, and the managers the datasets read (a dataset's edges lead to process views only). Pure.

_is_derived_table_paren

_is_derived_table_paren(flat: str, opening: int) -> bool

The parenthesis at opening opens a derived table: after FROM / JOIN, or after a comma of a FROM list (a comma of a SELECT list opens a scalar subquery). Pure.

_reads_at_own_level

_reads_at_own_level(body: str, pattern) -> bool

pattern finds a read that gives body (a parenthesised WITH body) its rows: at the body's own level or in a derived table, never inside a scalar or IN subquery. Pure.

_cte_names_reading

_cte_names_reading(flat: str, reads) -> List[str]

The WITH names of flat that stand for what the reads pattern finds: their body selects from it, directly or through another such name. A body that only filters on it through a scalar subquery holds source rows, so it does not stand for it. Pure, on the flattened upper-case text.

manager_read_shape

manager_read_shape(texts: Iterable[str], node: Optional[str]) -> dict

How the view SQL reads a TimeManager or FilterManager: {"scalar_columns": [...], "join": bool, "other": bool}.

Scalar = a one-table subquery used as a value (src.d <= (SELECT BUSINESS_DATE FROM tm), CAST((SELECT ...) AS DATE), a BETWEEN bound). Join = the manager in a JOIN or a comma list, as a table or as a derived table. Other = IN / EXISTS / ANY, or a whole SELECT over the manager, which another view then reads (an intermediate view: what that view does with it cannot be told from this step). Pure, on the flattened text.

shape_not_recognised

shape_not_recognised(shape: dict, texts: Iterable[str], node: Optional[str]) -> bool

The process's own SQL names the manager, yet :func:manager_read_shape found no read: the check saw nothing, which must not read as a pass. A manager its SQL does not name is read upstream (through a dataset), and there is no shape to judge. Pure.

time_filter_shape

time_filter_shape(texts: Iterable[str], tm_node: Optional[str]) -> dict

:func:manager_read_shape for a TimeManager (the name the callers already use).

_entity_for_source_column

_entity_for_source_column(r, source_column, source=None) -> Optional[str]

The entity column the view passes source_column of source (default: the largest source) as.

segments_follow_partitioning

segments_follow_partitioning(r) -> bool

A FilterManager column names a partitioning column of the largest source, directly or as the entity column the view passes it as. Pure.

skipped_partition_levels

skipped_partition_levels(r, source, levels) -> Optional[dict]

The higher levels of source's partitioning that a filter on a lower level leaves unfiltered, or None. A column the FilterManager or the TimeManager's scalar filter names counts (directly, or as the entity column the view passes it as). A filter on no level at all is not reported here: nothing says it applies to this source. Pure.

_fix_reregister

_fix_reregister(pids, pi=None, partitioning=None) -> str

_small_source_note

_small_source_note(mb, align_min_mb) -> str

No size gate on what the view's SQL does to a partitioned source: a process built on small lab tables meets large ones once migrated, so the finding says so instead of staying silent.

largest_source_has_own_finding

largest_source_has_own_finding(r) -> bool

The largest source's whole read is already told by another finding: the TimeManager scalar is on one of its partitioning columns (time_filter_defeats_pruning) or the FilterManager segments follow its partitioning. A manager that filters some other column does not cover it (a view can bound only a key table's date and join the historian unbounded, field report). Pure.

_whole_read_reported

_whole_read_reported(r) -> bool

partitioned_source_read_whole fires for the largest source of r. Pure.

_plan_sentence

_plan_sentence(r) -> str

What the plan read of the largest source shows. A statement about partitions needs a plan with the date known: a static plan understates elimination, and the SQL's shape alone proves nothing (a view can also filter that column in a form this check does not see). Pure.

distribution_findings

distribution_findings(rows: List[dict], *, align_min_mb: float = 1000, skew_threshold: float = 0.25, names=None) -> List[dict]

rows: one per process (see :func:collect_distribution). Grouped per (domain, entity key): the recommendation is for the entity, never one process. Pure.

_pid_in

_pid_in(obj) -> Optional[str]

The process id a finding's object ends with, as <view> (<process id>).

process_waves

process_waves(edges, pids, absent=()) -> Dict[str, int]

{pid: wave}: the execution waves of the process DAG (wave 0 = runs first), the same layering as :func:tdfs4ds.analyze_parallel_plan. Empty on a cycle; absent processes (unknown to the lineage graph) get no wave. Pure.

dimension_of

dimension_of(f) -> str

place_findings

place_findings(findings, procs, distribution=None) -> None

Give each finding the processes it concerns (pids), for the summary: its own process (object <view> (<pid>)), the processes of its entity (entity=(DOMAIN, KEY)) or those writing its table (table='DB.T'). A store-level finding (an entity column typed differently) keeps none. Pure.

health_model

health_model(procs, findings, unverifiable, checks, waves=None, names=None) -> dict

One row per process, ordered by execution wave, one cell per dimension: the worst severity of its findings, "ok" when the dimension was checked and found nothing, "n/a" when it was not (check not run, or not verifiable for that process). Also the verdict counts and the most frequent issues. Pure.

gap_branches

gap_branches(gaps) -> List[dict]

The dead branch each lineage gap leaves: [{"from", "kind", "branch"}], only the gaps whose branch is not empty. Pure.

_network_html

_network_html(model) -> str

The lineage network section: compilation, connected networks, dead branches. '' when the network check did not run.

_storage_level_note

_storage_level_note(model) -> str

Whether the storage level of the dataset check ran, and when ('' when the check was not part of the assessment).

_lineage_checked_html

_lineage_checked_html(model) -> str

What the lineage integrity check read and looked for ('' when it did not run).

refresh_note

refresh_note(model) -> str

What the refresh checks covered, as plain text ('' when neither ran). Pure.

_dataset_rows_summary

_dataset_rows_summary(rows) -> Optional[dict]

What the storage-level check covered (None when it did not run). Pure.

build_workflow_model

build_workflow_model(inputs: dict, *, skew_threshold: float = 0.25, skew_min_mb: float = 100, stuck_hours: Optional[float] = None, align_min_mb: float = 1000) -> dict

Findings, counts and what could not be checked. Pure.

_e

_e(v) -> str

render_executive_summary

render_executive_summary(model) -> str

The verdict, the most frequent issues and the health grid: one row per process, grouped by execution wave, one cell per dimension (worst severity; the issues in the tooltip). Scriptless HTML.

render_workflow_html

render_workflow_html(model, *, scan_hint=True) -> str

'Workflow assessment' body: the executive summary, then one group per area (the consistency style).

_md

_md(v) -> str

A Markdown table cell: pipes escaped, one line.

render_workflow_markdown

render_workflow_markdown(model) -> str

The assessment as Markdown: verdict, top issues, the health grid by wave, then the findings per area and what could not be verified.

network_markdown

network_markdown(model) -> List[str]

The lineage network section of the Markdown report ([] when not checked).

render_workflow_page

render_workflow_page(model) -> str

A standalone HTML page (the panel's content, for export): offline, no script.

_checks_not_run_note

_checks_not_run_note(model) -> str

Says which checks a report leaves out, so a clean report is never read as covering them.

write_workflow_report

write_workflow_report(model, out_path: Optional[str] = None, fmt: str = 'html') -> str

Write the assessment as html (standalone page), md or csv (findings) and return the path. Default path: DASHBOARD_REPORT_DIR.

findings_csv

findings_csv(model) -> str

_rows

_rows(sql) -> list

_query_df

_query_df(sql) -> pd.DataFrame

_err

_err(exc) -> str

_scope_processes

_scope_processes(proc: DataFrame, processes=None, data_domains=None) -> pd.DataFrame

read_followup

read_followup(process_ids, days: int = 90) -> pd.DataFrame

Follow-up rows of the processes started in the last days days (primary store).

read_dataset_modes

read_dataset_modes(datasets: DataFrame, max_ddl: int = 50) -> Dict[str, dict]

{dataset node: {"mode", "as_of", "tm"}} from the build view, then the view's DDL for a dataset without a build row (at most max_ddl reads).

read_expected_segments

read_expected_segments(proc: DataFrame, max_managers: int = 50) -> tuple

({pid: FilterManager rows}, unverifiable) - one COUNT per manager table.

read_chains

read_chains(proc: DataFrame, max_n: int = 100, emit=None) -> tuple

({pid: {"row", "chain"}}, unverifiable): the live SQL chain of each process (SHOW VIEW of its view and of the views it reads), read once and shared by the SQL drift and distribution checks; at most max_n.

read_versions

read_versions(process_ids, chains: Optional[dict] = None) -> tuple

(versions, drift, unverifiable) from FS_PROCESS_SQL (two reads) and the live chains read by :func:read_chains.

_probe_sql

_probe_sql(view, columns, pi) -> str

The staging CTAS of an ingestion, for EXPLAIN only (never executed).

_explain

_explain(sql) -> str

_segment_plan

_segment_plan(view) -> tuple

(plan text, dynamic): the plan of the process view for the active FilterManager segment, with incremental planning forced (DYNAMIC EXPLAIN, the segment's value known) when the session allows it, else the static plan. A static plan leaves the segment value as a parameter and understates partition elimination (seen live).

plan_access

plan_access(sql: str, source: str, *, dynamic: bool = True) -> Optional[str]

How the plan of the SELECT sql reads the table source ('DB.TABLE'): "partitions" (partition elimination, or a PTI time range), "all_rows", or None when no step reads it. dynamic=True plans with the subquery values known (DYNAMIC EXPLAIN with incremental planning forced, the session's query band restored); False is the static plan, which leaves a scalar subquery's value as a parameter. EXPLAIN only: nothing runs.

collect_distribution

collect_distribution(proc, feat, graph, chains, layout, expected_segments=None, max_explain: int = 30, emit=None, drivers=None) -> tuple

(rows, unverifiable): per denormalized-view process, its storage tables (PI, partitioning), its largest source (size, skew, PI, partitioning), the origin of each entity column, the aligned PI and the EXPLAIN evidence. Reads: the dictionary for the sources (batched) and at most max_explain x 3 EXPLAINs.

read_storage_layout

read_storage_layout(features: DataFrame) -> dict

Primary index, row counts, entity column types and AMP sizes of the storage tables (batched DBC reads). {"ok": False} when DBC is unreadable.

scan_entity_keys

scan_entity_keys(layout: dict, emit=None, run_sql=None, max_entities: Optional[int] = None) -> list

One :func:reduce_entity_key per (domain, entity key) of two columns or more, on its largest storage table (StatsV row count, else any).

read_dataset_rows

read_dataset_rows(reads, existing=None, emit=None, snapshot=None) -> tuple

The storage level of the dataset-feature check: rows per (FEATURE_ID, FEATURE_VERSION) of every storage table the datasets read (one grouped pass per table, now and over the whole history), and the COMPLETED runs of the producing processes. (rows, unverifiable); each failed read is an unverifiable entry, never an empty result read as "all fine".

collect_workflow_inputs

collect_workflow_inputs(processes=None, data_domains=None, checks=None, days: int = 90, max_sql_processes: int = 100, emit=None) -> dict

Everything :func:build_workflow_model needs. Each read is fail-open: a failure becomes an unverifiable entry, never an empty "all clear".

assess_workflow

assess_workflow(processes=None, data_domains=None, checks=None, entity_scan: bool = True, days: int = 90, display: bool = True, skew_threshold: float = 0.25, skew_min_mb: float = 100, stuck_hours: Optional[float] = None, align_min_mb: float = 1000, progress=None, dataset_rows: bool = True, closed_entities: bool = True) -> dict

Assess how the workflow is built: entity keys, run order and time synchronisation, point-in-time inputs, segments, process SQL, storage.

Parameters

processes : list of str, optional Process ids or view names to assess (default: every process). data_domains : str or list, optional Restrict to these data domains. checks : iterable, optional A subset of :data:CHECKS (default: all of them). entity_scan : bool Read the storage tables to test the entity keys (one grouped pass per entity over its largest table). False skips the only expensive read. dataset_rows : bool Count the stored rows behind every dataset feature (one grouped pass per storage table the datasets read). False keeps the dictionary-level checks only. closed_entities : bool Read the storage tables of each process whose close_absent_entities is off, for entities with no open validity period (closed_without_flag). False keeps the usage check (loops around run(), a view rewritten between runs, recursion). days : int Follow-up window, in days, for the run checks. display : bool Print a summary and the findings. progress : callable, optional Called with one line per step.

Returns

dict findings (area, kind, object, detail, severity, fix), counts, unverifiable (checks that could not run, with the reason), summary, entities (entity scan results), checks.

No language model is used, and nothing is changed: every finding names the command that fixes it.

sanity_check

sanity_check(out_path: Optional[str] = None, fmt: Optional[str] = None, *, processes=None, data_domains=None, scope: str = 'cheap', display: bool = True) -> str

Run the sanity checks and write the report, in one call.

Parameters

out_path : str, optional The report file. Default: DASHBOARD_REPORT_DIR, as in :func:write_workflow_report. fmt : str, optional 'html' or 'md' ('csv' gives the findings alone). Default: from the extension of out_path, else 'html'. processes, data_domains Restrict the checks, as in :func:assess_workflow. scope : str 'cheap' (default): the checks a migration report runs, closed entities included. 'full' adds the entity and dataset scans, which read every storage table the checks concern. The report names the checks it left out. display : bool Print the summary and the findings.

Returns

str The path of the report. For the findings as data, use :func:assess_workflow and :func:write_workflow_report.

No language model is used, and nothing is changed.

_print_model

_print_model(model) -> None