Skip to content

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. A version is stamped at the valid time the process writes its values at (FEATURE_STORE_TIME under a TimeManager or a roll_out, the run's real-time pin otherwise), the same valid time as the catalog row and as the values themselves. So the version that computed a stored value is simply the version in force at the value's ValidStart.

  • :func:version_segments (pure): version periods -> [{version, from, to}] over a window, with the time before the first version as None ("before versioning", never a guessed version).
  • :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_VERSION column per feature. The dataset view itself is never changed (backward compatibility).

qualified

qualified(database, object_name, force=False)

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

quote_ident(name, force=False)

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

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.

_execute

_execute(sql)

version_periods_sql

version_periods_sql(process_ids) -> str

The valid-time periods of every version of the processes (one row each).

version_segments

version_segments(periods: list, start=None, end=None) -> list

[{"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.

_window_bounds

_window_bounds(window) -> tuple

(start, end) of a HistoryWindow, evaluated in the database now.

_dataset_spec

_dataset_spec(dataset: str)

history_versions

history_versions(dataset: Optional[str] = None, *, process_ids=None, start=None, end=None) -> dict

The process versions behind a history, per feature (or per process).

Parameters:

Name Type Description Default
dataset Optional[str]

a historical dataset view ('db.view'); its features and its window are read from its DDL.

None
process_ids

instead of a dataset, {label: process_id} or a list.

None
start, end

the window (default: the dataset's, else everything).

required

Returns {label: {"process_id", "segments": [{"version", "from", "to"}], "versions": [...]}}; a version None is "before versioning".

describe_versions

describe_versions(versions: dict, fr: bool = False) -> list

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 process version in force at its ValidStart (NULL before versioning). The dataset view is read as is and never changed.