tdfs4ds.feature_props.checks¶
tdfs4ds.feature_props.checks
¶
On-demand check of stored values against declared properties (read-only).
Never called by run() / roll_out(): a declared property does not block, change or slow a run.
check_feature_properties is for sanity checks and the agent: one aggregate statement per storage
table (FS_T_*), scoped to the checked features' FEATURE_ID (and FEATURE_VERSION when the declaration
is for one process), at the current valid time, at as_of, or over the whole history.
RESULT_COLUMNS
module-attribute
¶
RESULT_COLUMNS = ['DATA_DOMAIN', 'ENTITY_NAME', 'FEATURE_NAME', 'PROCESS_ID', 'N_ROWS', 'N_OUT_OF_RANGE', 'N_NOT_ALLOWED', 'N_UNEXPECTED_NULL', 'FIRST_VIOLATION', 'ERROR']
feature_properties
¶
feature_properties(features: Optional[Iterable[str]] = None, data_domains: Optional[Iterable[str]] = None, as_of=None) -> pd.DataFrame
The declared properties of features, one row per (feature, process) rule.
Columns: DATA_DOMAIN, ENTITY_NAME, FEATURE_NAME, PROCESS_ID, VALID_MIN, VALID_MAX, ALLOWED_VALUES (list or
None), NULLABLE, NULL_MEANING, SENSITIVE (booleans or None), SENSITIVITY_REASON, AUTHOR, DB_USER, VALID_FROM.
as_of reads the declarations as they were at that valid time (VALIDTIME AS OF on the base tables,
primary store only). With read-only stores attached that offer the objects, the current read is their
union, the first store winning (a FEATURE_STORE column). An empty frame, with NO statement, when
nothing was ever declared in the store. Never raises on a read failure of an attached store.
run_frame
¶
Run one SELECT through teradataml.execute_sql and return a frame (no DataFrame metadata).
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).
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.
has_check
¶
Whether a rule declares something a stored value can break.
conditions
¶
{'oor', 'na', 'nl'}: the SQL predicates (or None) of a rule over FEATURE_VALUE.
check_sql
¶
check_sql(table: str, rules: List[dict], *, qualifier: str = 'CURRENT VALIDTIME', history: bool = False) -> str
One aggregate statement on one storage table (pure).
table: the qualified FS_T_* table. rules: dicts with feature_id, feature_type, vmin,
vmax, allowed (list), nullable (False = NULL not expected) and optionally process_id.
Columns per rule i: N_i rows, OOR_i out of range, NA_i not allowed, NL_i unexpected NULL
and, with history, FV_i the earliest ValidStart of a violating row. qualifier: CURRENT VALIDTIME,
VALIDTIME AS OF TIMESTAMP '...' or, with history, NONSEQUENCED VALIDTIME.
build_rules
¶
Join declared properties to the catalog (pure): one rule per property row that declares a check and whose feature is registered, with its stored type, FEATURE_ID and storage table.
producers: {(DOMAIN, ENTITY, FEATURE): {process ids}} (upper-case key). A rule that holds for every
producing process counts only the values of these processes (FEATURE_VERSION): stored values of a
removed process are kept by design and no dataset reads them. No producer known = every version.
producers_sql
¶
The current producing processes of the declared features (one read of the feature-split view).
_producers
¶
{(DOMAIN, ENTITY, FEATURE): {process ids}}; empty (= every version) when unreadable.
check_feature_properties
¶
check_feature_properties(features=None, data_domains=None, as_of=None, history: bool = False) -> pd.DataFrame
Count, per declared feature, the stored values that break its declared properties.
Columns: DATA_DOMAIN, ENTITY_NAME, FEATURE_NAME, PROCESS_ID, N_ROWS (stored values checked),
N_OUT_OF_RANGE (outside VALID_MIN / VALID_MAX), N_NOT_ALLOWED (not in the allowed values),
N_UNEXPECTED_NULL (NULL where NULLABLE = N), FIRST_VIOLATION (with history=True: the earliest
ValidStart of a violating row, else None) and ERROR (the database message when a table could not be
read; its counts are then None).
The values are read at the current valid time, at as_of, or over the WHOLE history
(history=True, NONSEQUENCED VALIDTIME, which can be expensive). One aggregate statement per
storage table. Read-only; never called by run() / roll_out(). No statement at all, and an empty
frame, when nothing is declared in the store.