tdfs4ds.dataset.catalog_columns¶
tdfs4ds.dataset.catalog_columns
¶
The dataset catalog holds everything needed to rebuild a dataset view (0.3.7.35). Pure: no database.
The view's text is what Teradata executes, but a lost view (DROP VIEW, a store restored without its
views) could not be recreated from the catalog: FS_<name>_FEATURES knows a feature's id, type and storage,
not the process version that produced it, the column alias, the join columns of a coarser feature nor the
order of the columns. They live in an optional table FS_<name>_COLUMNS (one row per output column of the
view: the entity columns and the feature columns, in the view's order), written by add_dataset next to
the build table (strategy, join type, temporal mode), the window table (history) and the offsets table
(lags and leads).
column_rows turns the specs the builders hold into those rows; spec_from_catalog reads them back
into a DatasetSpec that render_dataset_ddl renders to the same text as the view (byte for byte).
A dataset registered before 0.3.7.35 has no such rows: CatalogIncomplete says what is missing and how
to fill it (restore_dataset_catalog(dry_run=False) while the view still exists).
COLUMN_FIELDS
module-attribute
¶
COLUMN_FIELDS = ('COLUMN_ORDER', 'COLUMN_KIND', 'COLUMN_NAME', 'FEATURE_NAME', 'FEATURE_ID', 'FEATURE_VERSION', 'FEATURE_TABLE', 'DATA_DOMAIN', 'ENTITY_KEY', 'LEVEL_COLUMNS', 'STORAGE_ENTITY', 'LEFT_OUT', 'VERSION_LIST')
DERIVABLE_FIELDS
module-attribute
¶
DERIVABLE_FIELDS = ('COLUMN_ORDER', 'COLUMN_KIND', 'COLUMN_NAME', 'FEATURE_ID', 'FEATURE_VERSION', 'FEATURE_TABLE', 'LEVEL_COLUMNS')
_LITERAL_RE
module-attribute
¶
_LITERAL_RE = re.compile('\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[+-]\\d{2}:\\d{2})?')
_FIX
module-attribute
¶
_FIX = 'restore_dataset_catalog(dry_run=False) records it while the view still exists; a dataset whose view is already gone and was registered before 0.3.7.35 must be rebuilt with build_dataset'
DatasetSpec
¶
Everything needed to (re)generate a dataset view.
__init__
¶
__init__(entity, features, join_type='INNER', strategy=MULTIJOIN, time=None, schema_name=None, view_name=None, offset_strategy=None, partial=False)
FeatureSpec
¶
One feature column of a dataset view.
__slots__
class-attribute
instance-attribute
¶
__slots__ = ('table', 'feature_id', 'version', 'alias', 'from_version_list', 'offset', 'base_name', 'storage_entity', 'left_out', 'grain_checked', 'level')
__init__
¶
__init__(table, feature_id, version, alias, from_version_list=False, offset=None, base_name=None, storage_entity=None, left_out=(), level=None)
DatasetTime
¶
The resolved temporal mode of one dataset view.
Holds what the SQL needs (outer_qualifier, sub_qualifier) and what
the catalog records (mode, as_of, the TimeManager's location).
business_date_sql
property
¶
The manager's business date as a scalar sub-query (TIME_MANAGER only).
period_predicate
property
¶
Leading WHERE conjuncts selecting the valid instant, or ''.
Only the TIME_MANAGER mode needs one (see the module docstring for why
it is not an AS OF sub-query); for the other modes the qualifier
alone selects the instant, and the SQL is byte-identical to before.
__init__
¶
instant_sql
¶
The dataset's valid instant moved by offset, as a constant expression.
CURRENT: the query time; AS_OF: the literal; TIME_MANAGER: the manager's
business date, the shift inside the scalar sub-query so that it stays one
single-row read resolved once. Shifting the constant (never the
ValidStart / ValidEnd columns) keeps partition elimination: the
arithmetic is folded into a literal in the plan (verified on Vantage 20).
catalog_validtime
¶
The value written to DATASET_VALIDTIME (VARCHAR(255)).
CURRENT VALIDTIME or VALIDTIME AS OF TIMESTAMP '...' — the
qualifier the view carries — or TIME_MANAGER <db>.<view> for a
dataset following a TimeManager. A very long quoted manager name could
overflow the column, so it then degrades to the mode name; the build
table holds the full location anyway.
CatalogIncomplete
¶
column_rows
¶
Rows of the columns table for a dataset: entity columns first, then the features, in the view's order.
features are FeatureSpec; their base_name (catalog name), level, storage_entity and
left_out are recorded when known. ENTITY_KEY is the key the feature is stored at: its storage
entity (primary-index grain), else its join columns (coarser feature), else the dataset's entity.
column_rows_from_spec
¶
column_rows of a parsed DatasetSpec (the backfill of restore_dataset_catalog).
A parsed view says nothing about the catalog name of a feature, its domain, nor its storage entity:
previous (the rows already recorded) provides them for a column of the same name, so a repair never
erases what the builder knew. What the view's text determines (DERIVABLE_FIELDS) comes from the spec.
derivable_view
¶
What the view's text determines, comparable: [(field values...)] ordered by column order.
window_from_row
¶
The HistoryWindow of a window-table row, with its fixed bounds spelled as they were written.
The table stores the bounds as TIMESTAMP(0) WITH TIME ZONE (read back in the session zone); the
literal the view was built with is in WINDOW_TEXT, so it is read from there.
spec_from_catalog
¶
The DatasetSpec the catalog describes. Raises CatalogIncomplete when it cannot.
build: the dataset's row of the build table (dict); columns: its rows of the columns table; offsets: its rows of the offsets table; window: its row of the window table (history).