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.

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.
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.

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.

What it cannot see

  • 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.
  • 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. Compilation and the column list are checked; its values and its cost are not measured. The character set of a text column is not reported by the driver, so a text change is compared by length only.

See also Maintain a workflow and Good practices.