Skip to content

tdfs4ds.genai.documentation_visibility

tdfs4ds.genai.documentation_visibility

Valid time of the documentation rows (0.3.7.34).

Metadata is valid in REAL time: a documentation row is written with CURRENT VALIDTIME (valid from its write time, first load included) and the agent reads it at the current time; data (feature values) is valid in business time. So documentation that starts after the first business date is normal. The rule for writes is in :mod:tdfs4ds.genai.valid_from. This module:

  • :func:collect_visibility - the only I/O: first ValidStart per object of the business-dictionary tables and of the process documentation, the objects of each data domain, the first business dates;
  • :func:future_objects, :func:visibility_summary, :func:late_findings - pure: the sanity check documentation_valid_time reports documentation that starts in the FUTURE (a row dated forward by mistake is not read yet); the coverage card shows "Documented since" (oldest start) per data domain;
  • :func:late_objects / :func:backdate_documentation - an opt-in repair for an explicit wish to show the documentation at past business dates (a store read at a past valid time, an audit); not needed by the agent. dry_run=True by default: a NONSEQUENCED UPDATE of the rows that are the FIRST version of their part, so the history of later edits stays intact.

FUTURE_FIX module-attribute

FUTURE_FIX = 'Re-document the object (a later write is valid from now); tdfs4ds.backdate_documentation(valid_from=<past date>) moves a first version back'

FIX module-attribute

FIX = 'tdfs4ds.backdate_documentation(dry_run=False)   # preview first: tdfs4ds.backdate_documentation()'

BD_TABLES module-attribute

BD_TABLES = (('DOCUMENTATION_BUSINESS_DICTIONARY_OBJECTS', 'DATABASE_NAME', 'OBJECT_NAME', ()), ('DOCUMENTATION_BUSINESS_DICTIONARY_SECTIONS', 'DATABASE_NAME', 'OBJECT_NAME', ('SECTION_NAME',)), ('DOCUMENTATION_BUSINESS_DICTIONARY_COLUMNS', 'DATABASE_NAME', 'TABLE_NAME', ('COLUMN_NAME',)))

PROCESS_TABLES module-attribute

PROCESS_TABLES = (('DOCUMENTATION_PROCESS_BUSINESS_LOGIC', ()), ('DOCUMENTATION_PROCESS_FEATURES', ('FEATURE_ID',)))

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.

_u

_u(v) -> str

_ts

_ts(text)

_execute

_execute(sql)

late_objects

late_objects(vis: Dict[str, Any]) -> List[Dict[str, Any]]

The (object, data domain) pairs whose documentation starts after the first business date of the domain (the store's when the domain has none). Pure.

vis: {'objects': [{'object', 'kind', 'domains': [..], 'parts', 'first_valid'}], 'dates': {DOMAIN_UPPER: date, '': store date}}. An object with no known business date is not listed.

future_objects

future_objects(vis: Optional[Dict[str, Any]], now=None) -> List[Dict[str, Any]]

The (object, data domain) pairs with a documented part that starts in the FUTURE (after now, default the current UTC time). Pure.

visibility_summary

visibility_summary(vis: Optional[Dict[str, Any]]) -> List[Dict[str, Any]]

Per data domain: how many objects are documented, since when (the oldest first valid start) and how many start in the future (items). Pure.

late_findings

late_findings(vis: Dict[str, Any]) -> List[Dict[str, Any]]

Sanity findings (pure): one per (object, data domain) documented from a FUTURE time, documentation_valid_in_future. (Name kept; documentation after the first business date is normal.)

_in

_in(values: Iterable[str]) -> str

backdate_sql

backdate_sql(table: str, db_col: Optional[str], obj_col: str, key_cols: Sequence[str], database: Optional[str], names: Sequence[str], valid_from: str) -> str

NONSEQUENCED UPDATE moving back the rows that are the FIRST version of their part (pure).

A row qualifies when it starts after valid_from and no earlier row exists for the same part (same key); every later version is left as it is.

plan_backdate

plan_backdate(vis: Dict[str, Any], valid_from: Optional[str] = None, data_domain: Optional[str] = None) -> Dict[str, Any]

The objects to move and their statements (pure). Target date: valid_from, else the first business date of the object's domain (the earliest when it belongs to several), else 1900-01-01.

_first_valid_rows

_first_valid_rows(const: str, db_col: Optional[str], obj_col: str, keys: Sequence[str]) -> List[tuple]

[(db, obj, n_parts, earliest first start, latest first start)].

One NONSEQUENCED read per table, one row per part (the first start of a part is the start of its earliest version); the objects are aggregated here: a temporal qualifier cannot sit over a derived table (Error 9330) nor inside one (3706).

collect_visibility

collect_visibility(processes=None, datasets=None, graph=None) -> Dict[str, Any]

Read the first valid start of the documentation of every object the store concerns, the domains they belong to and the first business dates. Fail-open: a failed read is listed in errors (a Not verified entry), never raised.

_domains_by_object

_domains_by_object(proc_domain, datasets, graph) -> Dict[Tuple[str, str], set]

{(DB, NAME): {domains}} of the objects the store concerns: process views (their domain), the objects upstream of a process (read by it) and the datasets reading one (a dataset has the domains of the processes it reads). Pure over its inputs.

backdate_documentation

backdate_documentation(data_domain: Optional[str] = None, valid_from=None, *, dry_run: bool = True) -> Dict[str, Any]

Repair for an explicit wish to show the documentation at past business dates (a store read at a past valid time a past date, an audit); not needed by the agent, which reads at the current time. Moves the FIRST version of each documented part back, so the documentation is valid at every business date. Without valid_from: the first date of the data domain's clock, else 1900-01-01. Only a first version that starts later is touched (a NONSEQUENCED UPDATE of ValidStart); every later version, the history of later edits, is left as it is. data_domain None = every domain. Dry run by default.

Returns {'moved': [{'object', 'parts', 'from', 'to'}], 'sql': [...], 'applied': bool, 'errors': [...]}.