tdfs4ds.process_store.process_query_administration¶
tdfs4ds.process_store.process_query_administration
¶
quote_ident
¶
Return name as a Teradata identifier, quoting it only if required.
Idempotent: an already-quoted name is returned unchanged rather than being
wrapped a second time. Embedded quotes are escaped as "".
Parameters¶
name : str
The raw object/database name.
force : bool, default False
Quote even when the name does not need it. Use only at the few sites
that have always emitted unconditional quotes and whose exact output is
already baked into persisted DDL (see
feature_store/feature_query_retrieval.py) — elsewhere forcing would
change the SQL of existing stores for no reason.
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).
execute_query_wrapper
¶
Decorator to execute a query. It wraps around the function and adds exception handling.
This decorator is used to wrap around a function that generates a query and execute that query.
It handles exceptions during query execution and prints the error message along with the query.
The decorator works with both TeradataML's tdml and legacy tdml.get_context() execution methods,
depending on the TeradataML version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
function
|
Function to be decorated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
function |
Decorated function. |
Example
To decorate a function that generates and executes a query:
@execute_query_wrapper def my_query_function(): return "SELECT * FROM my_table"
This decorator can be applied to functions that generate and execute queries with ease.
list_processes
¶
Retrieves and returns a list of all processes from the feature store.
This function constructs and executes a SQL query to fetch details of all processes stored in the feature store. The details include process ID, process type, view name, entity ID, feature names, feature version, data domain, and metadata. The function handles different states of the feature store time, choosing either the current valid time or a specific timestamp based on the configuration. It also optionally prints the constructed SQL query, depending on the configuration. If the query execution fails, the function catches the exception, prints the error message, and the query for debugging purposes.
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame |
A pandas DataFrame containing the details of all processes in the feature store. The columns of the DataFrame correspond to the process ID, process type, view name, entity ID, feature names, feature version, data domain, and metadata. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the query execution fails, the function prints the exception message and the query. |
list_processes_feature_split
¶
Retrieves and returns a list of all processes from the feature store. The feature list is split to get one feature per row.
This function constructs and executes a SQL query to fetch details of all processes stored in the feature store. The details include process ID, process type, view name, entity ID, feature names, feature version, data domain, and metadata. The function handles different states of the feature store time, choosing either the current valid time or a specific timestamp based on the configuration. It also optionally prints the constructed SQL query, depending on the configuration. If the query execution fails, the function catches the exception, prints the error message, and the query for debugging purposes.
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame |
A pandas DataFrame containing the details of all processes in the feature store. The columns of the DataFrame correspond to the process ID, process type, view name, entity ID, feature names, feature version, data domain, and metadata. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the query execution fails, the function prints the exception message and the query. |
_remove_process_queries
¶
_remove_process_queries(process_id, nonsequence_validtime=True, drop_view=False, refresh_index=True)
The removal itself; returns the catalog DELETE statements, which the
decorator runs. See :func:remove_process.
remove_process
¶
remove_process(process_id, nonsequence_validtime=True, drop_view=False, refresh_index=True, force=False)
Deletes a process from the feature store's process catalog based on the given process ID, with what it leaves elsewhere.
Removed, before the catalog rows (each step non-fatal: a failure is logged as a warning and does not prevent the process from being removed):
- its documentation (business logic, features, EXPLAIN analysis, business dictionary entries of its view) and the provenance of that documentation;
- its entries in the vector index (Chroma: deleted by id; Teradata Vector Store: the collections are refreshed, since their embeddings are keyed by row position);
- its stored SQL versions (
FS_PROCESS_SQL) and its FilterManager / TimeManager catalog rows; - the lineage edges of its view, when the view no longer exists (
drop_view=Truedrops it first). A view kept after its process is removed is still a real object, so its edges stay.
The values the process stored in the FS_T_* tables are kept (their history).
Args:
process_id (str): The unique identifier of the process to be removed.
nonsequence_validtime (bool): When True (default), uses NONSEQUENCED VALIDTIME DELETE to
remove all temporal versions from the catalog.
drop_view (bool): Also drop the process view (default False).
refresh_index (bool): On the Teradata Vector Store backend, refresh the collections after the
documentation rows are deleted (default True). False leaves it to the next
build_vector_index().
force (bool): Remove it even when datasets read its values or other process views read its
view (0.3.3.27). By default the removal is refused with
tdfs4ds.dependencies.DependentObjectsError, which lists them in the order
they must be removed; tdfs4ds.plan_removal([process_id]) and
tdfs4ds.write_removal_script remove them all, in that order.
Each removal, and each refusal, is recorded in FS_REMOVAL_LOG (0.3.3.27,
tdfs4ds.get_removal_log()), with the view name so the process can still be named
once its catalog rows are gone.
Returns: None.
get_process_id
¶
Retrieves the process ID associated with a given view name in a database.
This function is designed to obtain the process ID for a specified view within a database.
Initially, it formats the provided view_name to conform to the database's naming conventions,
including handling scenarios where the view name is prefixed with a database name. After formatting
the view name, the function queries a list of processes using an assumedly predefined function
list_processes. It then filters this list to find the process corresponding to the formatted view name
and returns the associated process ID. The function assumes specific column names ('VIEW_NAME' and
'PROCESS_ID') in the data structure returned by list_processes and that these columns are in a
specific format (e.g., uppercase for view names).
view_name (str): The name of the view for which the process ID is to be retrieved. This can be either just the view name or a combination of database name and view name, formatted as 'database.view'.
int: The process ID associated with the given view name. This ID is retrieved from a list of processes, where it is associated with the view name that matches the input.
Raises: IndexError: If no process is found with the given view name.