tdfs4ds.dataset.history_versions¶
tdfs4ds.dataset.history_versions
¶
Which process versions computed the values of a history (0.3.3.12).
A feature's stored values all carry its process's PROCESS_ID, whatever SQL
computed them. The SQL beneath a process changes over time: its process version,
kept in FS_PROCESS_SQL. Since 0.3.7.34 versions are stamped in REAL time (the
database's clock at the write), while values carry business time. The link goes
through the run record in FS_FOLLOW_UP:
- a value stored from a business date
d: the latest COMPLETED run of the process withVALIDTIME_DATE = d; the version in force at that run'sSTART_DATETIMEcomputed it; - a real-time value (no dated run): the version in force at its
ValidStart; - a store written before 0.3.7.34 (versions stamped at business dates): when no run
matches, the version in force at
ValidStartis used, which was the old rule; - a
valid_time_columnprocess records no per-load start date: its version is reported asNone("not determined"), never guessed.
An unchanged value is not rewritten by the MERGE, so a later run with new SQL that gives the same value leaves the older period: the rule names the latest run covering that date.
- :func:
version_segments(pure): version periods ->[{version, from, to}]over a window, with the time before the first version asNone("before versioning", never a guessed version). - :func:
value_segments(pure): the same over business time, through the run record. - :func:
history_versions: per feature of a dataset (or for process ids), the versions inside a window. - :func:
history_with_versions: a companion view<view>_PV= the history plus a<feature>_PROCESS_VERSIONcolumn per feature. The dataset view itself is never changed (backward compatibility).
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).
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.
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.
version_periods_sql
¶
The valid-time periods of every version of the processes (one row each).
version_segments
¶
[{"version", "from", "to"}] along valid time, for one process.
periods: dicts PROCESS_VERSION, VALIDSTART, VALIDEND. Adjacent
periods of one version merge; the time before the first period is None
(before versioning). Clipped to [start, end); from None = from the
beginning, to None = still open.
_before
¶
a < b (a <= b with inclusive) as UTC instants; None = unbounded, False.
value_segments
¶
[{"version", "from", "to"}] along business (value) time for one process. Pure.
periods: version periods (dicts PROCESS_VERSION, VALIDSTART, VALIDEND,
real time); runs: follow-up rows {"VALIDTIME_DATE", "START_DATETIME", "STATUS"}.
Each business date with a COMPLETED run starts a segment whose version is the one in
force at that run's start; it lasts until the next dated run. Before the first dated
run, and for a process with no dated run, the version periods are used as they are
(real-time values, and stores written before 0.3.7.34). Clipped to [start, end).
_followup_runs
¶
{process_id: [{"VALIDTIME_DATE", "START_DATETIME", "STATUS"}]} from the
primary store's follow-up table (one read). Fail-open: {} when unreadable.
_valid_time_column_processes
¶
The processes that load with valid_time_column (their version is not
determined). Fail-open: an unreadable setting counts as none.
_window_bounds
¶
(start, end) of a HistoryWindow, evaluated in the database now.
history_versions
¶
The process versions behind a history, per feature (or per process).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Optional[str]
|
a historical dataset view ( |
None
|
process_ids
|
instead of a dataset, |
None
|
|
start, end
|
the window (default: the dataset's, else everything). |
required |
Returns {label: {"process_id", "segments": [{"version", "from", "to"}],
"versions": [...], "note"}} over business time, through the run record (see the
module docstring); a version None is "before versioning" (or "not determined"
for a valid_time_column process, with a note).
describe_versions
¶
One line per feature whose history spans several process versions.
history_with_versions
¶
history_with_versions(dataset: str, view_name: Optional[str] = None, *, replace: bool = False, return_query: bool = False)
Create <view>_PV: the history plus <feature>_PROCESS_VERSION per feature.
Each period gets the version that computed it, derived in SQL like
:func:~tdfs4ds.process_store.process_sql.value_version: the latest COMPLETED run
of the process with VALIDTIME_DATE = the period's ValidStart gives a real
start time, else the ValidStart itself (real-time values, and stores written
before 0.3.7.34); the version in force at that instant is joined from
FS_PROCESS_SQL (NULL before versioning). A valid_time_column process gets a
NULL column (not determined), decided when the view is created. The follow-up is a
plain table, so no temporal qualifier appears in the sub-queries. The dataset view
is read as is and never changed.