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.
qualified
¶
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).
split_qualified
¶
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
¶
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.
index_ids_to_remove
¶
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.
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
¶
own_clone_verdict
¶
May the soft clone <process view>_TM of a removed process be dropped? Pure (0.3.8.14).
Only when it is a view reading ANOTHER manager's _HIDDEN table (a soft clone; a hard copy
owns its dates and is never touched), no other process records it as its TimeManager and no
other object reads it. Returns {"drop": bool, "reason": str}.
_reader_still_exists
¶
True unless the dictionary says the lineage node DB.OBJECT is gone.
drop_own_time_clone
¶
Drop the soft clone <view>_TM that registration made for this process next to its view,
after the process view itself was dropped (remove_process(drop_view=True)). Never raises;
returns what was done. Kept, with the reason, whenever anything else may still use it.
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
¶
{"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
¶
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
¶
[(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.
_producer_views
¶
[(PROCESS_ID, VIEW_NAME)] of the processes that compute the feature.
feature_removal_scope
¶
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.
_triplet_sql
¶
(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
¶
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
¶
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 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.