Skip to content

tdfs4ds.removal

tdfs4ds.removal

What a removed process or feature leaves behind, and its removal (0.3.3.12).

remove_process and remove_feature used to delete the catalog rows (and, for a process, its documentation tables) and nothing else. Left behind were:

  • the vector-store entries of the documentation (the agent could still find a removed process or feature by search);
  • the documentation provenance rows;
  • the stored SQL versions (FS_PROCESS_SQL) and the FilterManager / TimeManager catalog rows of a process;
  • the lineage edges of a dropped process view.

The helpers here remove them. Every step is independent and non-fatal: a failure is logged and reported, never raised, so a partial cleanup never stops the removal itself.

Lineage. The lineage graph holds objects, not processes. A process view kept after its process is removed is still a real view that other objects may read, so its edges stay; they are removed when the view is gone (remove_process(..., drop_view=True)). A feature is not a node of the graph: removing one leaves the graph unchanged.

Vector store. Chroma: the entries of the object are deleted by id (the ids build_vector_index gives them). Teradata Vector Store: a collection reads the business-dictionary view live, but its embeddings are keyed by row position, so deleted rows must be followed by a refresh (build_vector_index, which uses update(data_refresh=True)); refresh_index=False skips it and says so.

logger module-attribute

logger = getLogger(__name__)

_SOURCES module-attribute

_SOURCES = ('objects', 'sections', 'columns')

_BATCH module-attribute

_BATCH = 200

split_qualified

split_qualified(name)

Split db.obj into (database, object), both de-quoted.

Quote-aware, so a dot inside a quoted part does not split the name: split_qualified('"DEINF.CARLOSN"."FS_X"') == ('DEINF.CARLOSN', 'FS_X'). The naive rsplit('.', 1) this replaces returns ('"DEINF.CARLOSN"', '"FS_X"') only by luck and ('"DEINF', 'CARLOSN"."FS_X"') in the split('.') variant.

An unqualified name returns ('', name).

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.

_norm

_norm(s) -> str

index_ids_to_remove

index_ids_to_remove(source: str, ids, database: str, object_name: str, columns=None) -> list

The ids of source ('objects' / 'sections' / 'columns') that belong to the object, among ids. With columns, only those columns (columns collection).

Ids are DB__OBJ (objects), DB__OBJ__SECTION and DB__OBJ__COLUMN, as build_vector_index writes them; compared case-insensitively.

_execute

_execute(sql)

_step

_step(report: dict, name: str, fn)

remove_from_vector_index

remove_from_vector_index(database: str, object_name: str, *, columns=None, refresh_index: bool = True) -> dict

Remove an object's documentation (or only some of its columns) from the vector index. Never raises. Returns {"backend", "removed" | "refreshed", ...}.

_delete_provenance

_delete_provenance(db: str, obj: str, part: Optional[str] = None, part_name: Optional[str] = None)

remove_process_leftovers

remove_process_leftovers(process_id: str, view_name: Optional[str], *, purge: bool = True, refresh_index: bool = True) -> dict

Everything a process leaves outside its catalog and documentation tables.

Called by remove_process after the documentation is deleted and before the catalog rows are. Never raises; returns a report.

_find_dataset

_find_dataset(dataset: str) -> Optional[dict]

{"dataset_id", "database", "name"} of a registered dataset of the primary store, by DATASET_ID, db.name or bare name; None when unknown.

_bd_counts

_bd_counts(db: str, obj: str) -> dict

Current business-dictionary rows of an object, per table.

remove_dataset

remove_dataset(dataset: str, *, drop_view: bool = False, purge: bool = False, dry_run: bool = True, refresh_index: bool = True, force: bool = False) -> dict

Remove a dataset from the catalog, with what it leaves behind (0.3.3.19).

dataset: its DATASET_ID, database.name or name. Removes the catalog, entity, feature, build and window rows and closes its lineage edges (drop_dataset), then its business-dictionary rows (description, sections, columns), their provenance and its vector-index entries. The view itself is kept unless drop_view=True.

dry_run=True (default) changes nothing and returns what would go, with the processes whose view reads it (dependents). Only a dataset of the primary store can be removed. A dataset that process views read is not removed unless force=True (0.3.3.27): tdfs4ds.dependencies.DependentObjectsError lists them in the order they must be removed. Every step after the catalog is non-fatal and reported; the call raises only when the dataset is unknown or ambiguous, or when the catalog rows cannot be removed.

_producers_from

_producers_from(procs, doc_pids, feature_name: str, entity_id, data_domain: str) -> list

[(PROCESS_ID, VIEW_NAME)] of the processes computing a feature, from the process catalog frame procs and the PROCESS_IDs documenting its FEATURE_IDs (doc_pids). Pure: shared by :func:_producer_views and :func:remove_features.

_process_frame

_process_frame()

_producer_views

_producer_views(feature_name: str, entity_id, data_domain: str, feature_ids) -> list

[(PROCESS_ID, VIEW_NAME)] of the processes that compute the feature.

feature_removal_scope

feature_removal_scope(producer_ids, process_id: Optional[str] = None) -> dict

What remove_feature removes (0.3.3.23, pure).

A feature (data domain, entity, name) has ONE catalog entry, whatever the number of processes computing it. Without process_id the whole feature goes ("full", the historical behaviour). With it, the catalog entry goes only when no OTHER process computes the feature; otherwise only that process's part goes ("process": its documentation of the feature), and the catalog entry stays for the others.

A process_id absent from producer_ids (already removed, or never a producer) is not an error: the decision rests on the other producers.

remove_feature_leftovers

remove_feature_leftovers(feature_name: str, entity_id, data_domain: str, feature_ids, *, refresh_index: bool = True, process_ids=None, producers=None) -> dict

The feature's documentation and index entries, for every process computing it.

feature_ids: the catalog FEATURE_IDs of the feature, read before its catalog rows are deleted. process_ids: only these processes' documentation of the feature (remove_feature(..., process_id=) on a shared feature, 0.3.3.23); None = every producer. producers: [(PROCESS_ID, VIEW_NAME)] when the caller already read them. Never raises; returns a report.

_chunks

_chunks(seq, n=_BATCH)

_triplet_sql

_triplet_sql(items) -> str

(FEATURE_NAME = .. AND DATA_DOMAIN = .. AND ENTITY_NAME = ..) OR ... for [(name, domain, entity_text)]: the predicate :func:_remove_feature uses for one.

feature_batch_statements

feature_batch_statements(features: list, *, provenance: bool = True) -> list

The deletes of :func:remove_features, grouped (pure). Returns [(label, sql)].

features: one dict per feature with name, domain, entity (the ENTITY_NAME text), ids (its FEATURE_IDs), mode ('full' or 'process', from :func:feature_removal_scope), process_id and producers ([(PROCESS_ID, VIEW_NAME)] whose documentation goes).

Per feature, the same rows as remove_feature(..., force=True): its process documentation (every producer, or only process_id in 'process' mode), the business-dictionary column and its provenance on each of those producers' views, and, in 'full' mode only, the catalog entry (last). One statement per kind and per chunk of 200, instead of one per feature and producer.

resolve_feature_batch

resolve_feature_batch(feats: list, id_rows, doc_rows, procs) -> list

Fill each feature's ids, mode and producers (pure).

id_rows: (FEATURE_NAME, DATA_DOMAIN, ENTITY_NAME, FEATURE_ID) of the catalog; doc_rows: (PROCESS_ID, FEATURE_ID) of the process documentation; procs: the process catalog frame. Returns the reports.

remove_features

remove_features(items, *, refresh_index: bool = True) -> list

Remove several features in one pass (0.3.7.21): the batched form of remove_feature(feature_name, entity_id, data_domain, process_id, force=True).

items: dicts with feature_name, entity_id, data_domain and optionally process_id (the arguments of the remove_feature steps of a removal plan). Each feature is removed as one remove_feature call would (same rows, same 'full' / 'process' decision), but reads and deletes are grouped: about ten statements in all instead of about a dozen per feature, and ONE refresh of a Teradata Vector Store instead of one per feature. The dependency guard is not run (a plan already ordered the removal); each feature still gets its own row in the removal log.

Returns one report per item, in order: {"feature", "mode", "others", "listed"}, or {"feature", "error"} for every item when the processes could not be read (nothing is removed then, as remove_feature does for one). Raises when the catalog delete fails; the removal log rows then say FAILED.