Skip to content

Study the impact of a change

Before you edit a process, a view, a source table or a dataset, tdfs4ds.impact_of tells you who reads it, which readers the change would break or give other values, and which calls to make afterwards. It is read only: it runs SELECT, HELP, SHOW and EXPLAIN, and asks the database to describe the proposed SQL without executing it. Nothing is created, altered or run by impact_of. The measured comparison is the one opt-in step that creates objects: two volatile tables, dropped at the end (see Measure on volatile tables).

Use with expert review

These checks are not exhaustive and can report false positives: have an expert review the findings. They support experts, they do not replace them. A finding is a lead to investigate, not a verdict. The study is read from the SQL and the catalogs: estimates are not measurements, and readers outside the store are not seen. The absence of a finding is not proof that nothing is affected.

Before the edit

import tdfs4ds

# 1. Who reads it? A process id, a process view, a dataset, a plain view or a source table.
#    db.name is accepted.
tdfs4ds.impact_of('MY_DB.CUSTOMER_FEATURES')

# 2. What would this new SELECT do? (a REPLACE VIEW ... AS header is accepted)
model = tdfs4ds.impact_of('MY_DB.CUSTOMER_FEATURES', new_sql="""
    SELECT CUSTOMER_ID
         , SUM(AMOUNT) AS TOTAL_SPEND
    FROM MY_DB.TRANSACTIONS
    GROUP BY CUSTOMER_ID
""")

# 3. What would this dataset change do?
model = tdfs4ds.impact_of('MY_DB.DS_CUSTOMER', dataset_change={'remove_features': ['MAX_SPEND']})

display=True (the default) prints a text report. The call also returns the model, a dict you can read in code (display=False to print nothing).

What it reports

Key Content
targets The objects resolved, with their kind (process, dataset, view, table, attached view, manager). A process lists its features and the datasets reading them.
change For new_sql: columns added, removed and changed (with the type class), features no longer produced, feature types against the stored ones (fits, wider, incompatible), features whose computation changed, structural differences of the logic (a lost predicate, another grain, a lost DISTINCT, other join types), managers read before and after, source tables dropped or added. For dataset_change: columns that disappear, a change of rows (join type or time).
target_verdict The verdict on the edited object itself.
features The feature-level reading (schema_version 2): one entry per edited feature or column, with its state, severity, evidence, readers and chain. See Feature level.
feature_edges The chain of features, edge by edge, each with its severity and reason.
severity_counts The distinct features and columns of the study, by severity.
dependents The readers grouped by object: their severity, whether they were narrowed, the features affected and not affected, and why.
efficiency With new_sql: the EXPLAIN comparison of the current and the proposed SELECT (faster, same, slower, not_comparable). See Efficiency.
downstream The readers, grouped as processes, datasets, attached_views, views, managers (including TimeManager soft clones) and tables. Each carries its distance and its verdict.
verdicts One line per reader: object, kind, verdict, reason.
after The ordered calls to make afterwards, as text. Nothing in it was run.
unverified What could not be read, with the command that fixes it.
limits What the analysis cannot see.

Reading the verdicts

Verdict Meaning
breaks The reader uses a column or feature the new SQL no longer produces, the entity key changes, a feature type is incompatible with the stored one, or the proposed SQL does not compile.
values_change The reader keeps working but gets other values: a column whose type or computation changes, or a change of logic that moves every value (a lost filter, another grain, other source tables).
unaffected The reader's SQL names none of the changed columns and the logic is unchanged.
not_verifiable The reader's SQL could not be read (no right, too many readers) or the features it takes from the process could not be listed.
depends You described no change: the reader reads the object, nothing more is known.

A dataset reads features by id, not by column name. A dataset that reads a feature the process no longer produces keeps returning the last stored values and is reported as breaks: tdfs4ds also refuses to remove the feature while the dataset reads it.

Missing lineage is not 'no dependents'

If the persisted lineage graph is empty, or the object is not in it, the readers through views are unknown. impact_of says so under unverified and gives the tdfs4ds.rebuild_lineage_graph(...) command. The datasets that read the process's features are still found, through the dependency model.

Feature level

impact_of judges each reader as a whole. The model also reads the study feature by feature, from the same inputs and with no extra database read. features=False leaves that reading out; the other keys do not change.

For each feature, or column, of the edited object, features gives:

Field Content
state unchanged, logic_changed (its computation changes), type_changed, removed (no longer produced), added (new: nobody reads it yet) or unknown (it could not be compared, for example because the proposed SQL does not compile).
severity breaks: it can no longer be computed, or a reader stops working on it. values_change: its readers get other values. may_change: the values may change and the reading could not narrow it down. unaffected: nothing changes for it.
evidence semantic (read from the SQL) or measured (compared on volatile tables, see Measure on volatile tables).
readers Each object that reads the feature, with the features or columns of that object that are affected and those that are not.
chain The features computed from it, edge by edge (feature_edges), each edge with its reason. The chain is followed for up to max_depth rounds (default 6).

severity_counts gives the number of distinct features and columns of the study at each severity: the edited ones, and every reader feature or column that the chain reaches. dependents regroups the same reading by reader: one entry per object, the most severe first, with its features and why they are affected.

model = tdfs4ds.impact_of('MY_DB.CUSTOMER_FEATURES', new_sql=NEW_SQL, display=False)

model['features']          # one entry per edited feature: state, severity, evidence, readers, chain
model['severity_counts']   # distinct features and columns, by severity
model['dependents']        # one entry per reader: severity, narrowed, affected and unaffected features

Narrowed or not narrowed

A reader is narrowed when the reading can say which of its columns move:

  • a dataset reads features by id, so exactly the columns of the changed features are affected. A removed feature freezes its column at its last values; then an INNER join loses the rows of the dataset, and a FULL OUTER join keeps them with the column NULL;
  • a process, a view or an attached view has its SQL split into output columns. Only the columns whose expression names a changed column (or passes it through) are affected.

A reader is not narrowed when a changed column appears outside its select list, or when its select list cannot be split: a SELECT *, a changed column named in the FROM, WHERE or JOIN clauses, or a select list the reading cannot split. Its severity is then at least may_change, every output column is marked may_change, and its consequence says not narrowed: the whole object is assumed affected.

Efficiency: compare the plans

With new_sql, efficiency compares the plan of the current SELECT (SELECT * FROM <object>) with the plan of the proposed one. Only EXPLAIN and DYNAMIC EXPLAIN are sent, each checked before it leaves. Nothing is run. A DYNAMIC EXPLAIN is made under forced incremental planning, the way the workflow assessment reads a manager's value; the session's query band is set and restored around it.

The block gives the verdict, the reason, a table of metrics (est_seconds, spool_gb, steps, product_joins, all_rows_scans, partitions_read, confidence: current, proposed and delta), plan_kind (dynamic or static) and notes.

Verdict When
slower The proposed plan adds a product join, or an all-rows scan of a large table (1,000,000 rows or more estimated), or an intermediate result too large to estimate, even when its estimates were made with low confidence. Otherwise, its estimated time is more than 15 % higher (when either plan is estimated at one second or more) and both estimates are confident.
faster Its estimated time is more than 15 % lower (same one-second floor). Without a time difference, it has fewer product joins or all-rows scans.
same Within 15 %, and the same plan shape.
not_comparable One of the EXPLAINs failed, or there is no cost signal and the step that dominates the time of either plan was estimated with low confidence (statistics missing). The reason names the side and the cause.

A cost signal (a new product join, a large all-rows scan, a spool that cannot be estimated) decides first. The plan shows it even when its row estimates are uncertain, so a proposed plan estimated with low confidence is still slower on such a signal; a note says the proposed estimate is partly low-confidence. Then the times decide, but only from confident estimates. Fewer product joins or scans only count when the times do not.

Confidence is weighed on the dominant step: the step with the largest estimated time. A plan whose low-confidence estimates are all on small steps reads partial in the confidence metric, and its time still counts (with a note). A plan whose dominant step is low-confidence reads low.

These are the optimizer's estimates, not measurements. When DYNAMIC EXPLAIN is not available, the static plans are compared (plan_kind static), which can understate partition elimination; the notes say so.

The process's own runs as the reference

When the edited object is a registered process, efficiency.reference holds its execution log, read with SELECTs only (tdfs4ds.impact_reference.read_execution_reference):

Key Content
n_runs The runs used: the last 10 runs whose every segment or date completed. The durations below count one execution per follow-up row (one date or one segment), the unit of an incremental process.
duration_s median, max and last duration of those runs, in seconds (first start to last end).
cpu_s, io, spool_gb Median CPU seconds, I/O and largest spool per run, when the optional FS_EXECUTION_RESOURCES history holds them.
source resources (CPU history read), follow_up (durations only) or none (no completed run, or not a process).
comparison The proposed estimate stated against the history, for example "the original process takes about 6 s per run (median of 10 logged run(s), ...); the proposed plan is estimated at 9.3 s (1.5 times the logged median)".
note What the figures are, or why there are none.

A logged duration covers the whole run: computing the view, staging, the MERGE into the feature tables and the statistics. It is a reference for the order of magnitude, not the time of the SELECT alone. Without a log, the reference says so and the generic limits apply.

Measure on volatile tables (on demand)

The estimate can be checked by running both SELECTs. The measured comparison is opt-in and you start it: from the Impact study panel (Measure on volatile tables, after a study in New SQL mode), or with run_study(..., measure=True) from tdfs4ds.impact_agent. The impact agent's planner cannot start it.

What runs, in this order:

  1. Gate. Both SELECTs are checked with EXPLAIN before anything is computed. The limits are SAMPLE_MAX_SECONDS (60) and SAMPLE_MAX_SPOOL_GB (10). For a process with logged runs, each limit grows to three times the logged median (time, and spool when harvested) when that is higher, so a SQL is refused only when it is clearly beyond its own history. An estimate above the limits is refused. Low confidence waives the refusal only for a plan with no product join and no spool over the limit: such a plan runs, with a note. Measure anyway runs it regardless.
  2. Compute. The current and the proposed SELECT are computed in full as two volatile tables, TDFS_IMPACT_OLD and TDFS_IMPACT_NEW, in a session of their own (not the shared teradataml connection). Each is timed, and its row count and columns are read. A leading locking modifier (LOCKING ROW FOR ACCESS, LOCKING TABLE ... FOR ACCESS, LOCK ...) and the comments are dropped from the copy's SELECT, because CREATE VOLATILE TABLE ... AS (LOCKING ... SELECT ...) is refused (Error 3707); the copy only reads, and a note says so.
  3. Compare. The two results are compared on the entity key, column by column, NULL-safe: the rows that differ in each column, examples (up to five rows present in both results, with the entity key, the current and the proposed value, shown in one expandable panel per column in the panel and the reports), the entities present on one side only, and the identical columns.
  4. Drop. The two tables are dropped in a finally, and HELP VOLATILE TABLE checks that they are gone.

Nothing is stored: no catalog row, no follow-up row, no permanent object. Only an allow-list of statements is sent (SELECT, EXPLAIN, HELP VOLATILE TABLE, the query band TDFS_IMPACT=<id> of the measuring session, and the create and drop of these two tables). Anything else is refused before it reaches the database. The EXPLAIN comparison of the study is not part of this allow-list: its DYNAMIC EXPLAIN runs under forced incremental planning, which sets a session query band on teradataml's connection and restores it afterwards.

There is no row limit and no SAMPLE. A Teradata sample is random, so two samples cannot be compared row by row. A process view is already scoped by its managers (the TimeManager and FilterManager scalars), so its full result holds one run's rows; compare that, NULL-safely.

The run can be cancelled from the status bar: the running statement is stopped in the database, and the job ends as cancelled. It also stops after SAMPLE_JOB_MAX_SECONDS (600).

After the measurement, measure.reference puts the measured seconds of both SELECTs beside the logged runs of the process. The logged durations include the ingestion, so they are a reference, not a target.

The CPU, I/O, peak spool and CPU skew of the two CREATEs come from DBQL (DBC.QryLogV: AMPCPUTime, TotalIOCount, SpoolUsage, MaxAMPCPUTime against NumOfActiveAMPs). DBQL writes its rows from a cache (10 minutes by default), so they are usually not there when the comparison ends. The measuring session is tagged with a query band (TDFS_IMPACT=<id>), which finds exactly its two statements:

  • Wait for DBQL (in the confirm line, on by default, up to 15 minutes, 1 to 60): the job reads DBQL again every 30 s until both CREATEs are logged. Cancelling from the status bar stops the wait only; the comparison is kept. In Python: tdfs4ds.impact_measure.wait_for_resources(tag=..., timeout_s=900).
  • Later: Refresh resource figures in the Study tab (GET /ui/impactstudy/measure/resources, or tdfs4ds.impact_measure.read_resources(tag=...)).

Once both are logged, measure.resource_delta states the proposed/current ratios, for example "Proposed vs current, measured by DBQL: CPU x2.5, I/O x0.5, peak spool x1." Reading DBC.QryLogV needs SELECT on it and DBQL logging for the user; without them the figures stay empty and the reason is shown.

The report (HTML, Markdown, and the app's Report tab) also shows the current and the proposed SELECT side by side, removed lines marked on the left and added lines on the right (Markdown: both texts and a unified diff). The REPLACE VIEW ... AS header is set aside on both sides.

A view with no entity key cannot be compared row by row, so it is not measured.

Evidence: semantic or measured

Each feature keeps its reading from the SQL (evidence: semantic) until a measurement compares it (evidence: measured):

  • a feature whose values differ keeps its severity, raised to at least values_change; its reason gives the count (values differ for N of M entities (measured));
  • a feature whose values are identical goes to unaffected, and so do its readers and the edges of its chain: the chain stops there. Its reason says values identical (measured).
  • a feature whose values are identical but whose type changed (for example retyped to DECIMAL(18,4)) stays unaffected for its values and gets type_note: "type changed: values identical, readers that cast or compare this column should be checked". The dependents reading it list the note in type_notes; the Features tab, the dependents view and the report show it. The severity is not raised.

The measurement covers the features of the edited object, on its entity key. Its readers are not measured: each keeps the reading from its SQL.

Report

write_impact_report(model, path=None, fmt='html') writes a study to a file and returns its absolute path. It is in the tdfs4ds.impact_report module; it is not exported at the top level of tdfs4ds.

Format Content
html One self-contained page: scoped styles, no script, no external request.
md Markdown with the same sections.
csv One row per affected feature of each reader, with the columns edited_feature, edited_process_id, affected_object, affected_kind, affected_feature, severity, reason, consequence, evidence and explanation.

render_impact_report(model, fmt) returns the text instead of a file. Without a path, the file goes to IMPACT_REPORT_DIR when that Python setting is set, else to a temporary folder. The agent's block appears in the report only when the agent was used, and its wording is labelled as written by the assistant, unverified.

The panel's Report tab offers the same three formats as downloads.

Apply the change

impact_of changes nothing. Apply the SQL yourself, then register again if the features changed:

  • a plain view, or the SQL of a process whose features are unchanged: REPLACE VIEW the view;
  • a process whose features changed: tdfs4ds.upload_features(...) again (it refuses a feature type that no longer fits the stored one and prints the way out);
  • a dataset: tdfs4ds.build_dataset(...) again with the new feature list, join type or time.

If the report lists plan_type_change as the first step, run it before applying: a stored type has to be widened, with its history, before the process can write the wider values.

After the edit

after lists the calls that apply, in this order:

  1. tdfs4ds.plan_type_change(...) before the edit, only when a type no longer fits.
  2. tdfs4ds.rebuild_lineage_graph(objects=[...], check=True): refreshes the edges of the edited object and compiles every process downstream of it.
  3. The datasets that broke are built again without the feature that is gone.
  4. tdfs4ds.remove_feature(..., process_id=...) for a feature the process no longer produces, once no dataset reads it (tdfs4ds.plan_removal shows the dependents first).
  5. A recompute for the processes whose values change: tdfs4ds.roll_out(process_list=[...], time_id_start=1, force_compute=True) when a TimeManager drives them (the history is replayed from its first date), tdfs4ds.run(<process id>, force_compute=True) otherwise. Downstream processes recorded COMPLETED on the old values and are skipped unless forced.
  6. tdfs4ds.rebuild_documentation(objects=[...]): the edited objects and everything downstream.
  7. tdfs4ds.sanity_check(processes=[...]).

Worked examples

Remove a feature from a process

import tdfs4ds

model = tdfs4ds.impact_of('MY_DB.CUSTOMER_FEATURES', new_sql=NEW_SQL_WITHOUT_MAX_SPEND)

model['target_verdict']
# {'verdict': 'values_change', 'reason': 'no longer produces MAX_SPEND'}

[(v['object'], v['verdict']) for v in model['verdicts']]
# [('MY_DB.DS_CUSTOMER', 'breaks'), ('MY_DB.V_REPORT', 'breaks'), ('MY_DB.SCORING (p3)', 'unaffected')]

The dataset reads MAX_SPEND, and the attached view V_REPORT names it. The scoring process reads the dataset but names only other columns, so it is unaffected. Rebuild the dataset without MAX_SPEND, remove the feature, then follow after.

Widen a feature type

A feature stored as DECIMAL(10,2) now computed as DECIMAL(18,4) is reported as wider: the process is values_change and after starts with plan_type_change before the edit. An incompatible type (a number that becomes text) is reported as breaks: choose another feature name or cast the column in the view.

Edit a plain view or a source table

For a plain view, pass new_sql as for a process. For a source table nothing can be compared: impact_of('MY_DB.TRANSACTIONS') lists every process, dataset and view that reads it, with the verdict depends. Use it to choose what to recompute after a load that changes the data.

Change a dataset

dataset_change takes remove_features (feature names or dataset columns), add_features, join_type ('INNER' or 'FULL OUTER') and time ('current' or anything else). Removing a column is judged by the readers' SQL; a change of join type or time changes the rows, so every reader is values_change.

Where the parser could not follow

Some SQL resists a parser: table operators and EXECUTE FUNCTION, TD_* analytic functions, user-defined functions, PIVOT / UNPIVOT, JSON and XML shredding, WITH RECURSIVE, dynamic SQL, QUALIFY over a derived column. The study lists every SQL text that holds one (the proposed SQL, the edited objects, the readers) under Where the parser could not follow, with the constructs found, whatever the agent setting: the findings about these objects may be incomplete, so have an expert review them. With the impact agent on, a model gives an opinion on them, beside the code's finding.

What stays outside

  • Object-level lineage. Readers come from the persisted lineage graph and the dependency model. Keep the graph current with tdfs4ds.rebuild_lineage_graph.
  • Column-level reasoning is by name. A reader is judged by the changed columns its SQL names, or by SELECT *. An expression is judged by the columns it names, not by what it computes. The feature-level reading follows the same rule.
  • Readers outside the feature store (a BI tool, a script, a user's own view) are invisible unless their view is attached with tdfs4ds.attach_objects. DBQL readers are not listed.
  • The proposed SQL is prepared, not executed. impact_of checks that it compiles and compares its column list. Its plans are compared as the optimizer's estimates. Its values and its real cost are seen only with the measured comparison, which is opt-in and computes both results in full. The character set of a text column is not reported by the driver, so a text change is compared by length only.
  • Estimates depend on statistics. A plan whose statistics are missing is not_comparable, not faster or slower.
  • The measurement covers one object. It compares the edited object's own features on its entity key, not what its readers return.
  • The impact agent (optional) never changes a verdict. See Impact-study agent.

See also Maintain a workflow and Good practices.