tdfs4ds.dataset.read_at¶
tdfs4ds.dataset.read_at
¶
Read a registered dataset at a business date, with no DDL (0.3.8.0).
dataset_sql(name, as_of=...) returns the dataset's own query for one business
date; read_dataset(name, as_of=...) runs it. Nothing is created and no
TimeManager cursor moves: the date is a literal in the query. The query is the one
the dataset view holds (read_dataset_spec reads the view's DDL, the dataset
catalog stands in when the text cannot be read), with its temporal mode replaced
by AS OF <literal> - same select list, joins, offsets, grouping and nested
levels. A historical dataset is refused: filter the history view itself.
What a bare date means. build_dataset(as_of='2024-03-31') reads the date at
midnight in the SESSION's time zone. Here the date is a BUSINESS date, read at
midnight in the zone the store's dates are written in:
- a dataset that follows a TimeManager: the zone of that calendar's dates;
- otherwise the data domain's clock calendar, when the domain has one;
- with neither:
+00:00.
A calendar of DATE / TIMESTAMP without zone stores no zone: its dates were
stamped in the session zone of the run, and the manager's own scalar is cast in the
session zone too, so the literal gets no offset (same reading as a moved cursor).
A timestamp that carries an offset is used as given.
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.
logger_safe
¶
Wrapper around the global logger that only emits logs when
tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.
format_timestamp_literal
¶
Normalise value to the body of a Teradata TIMESTAMP '...' literal.
Returns 'YYYY-MM-DD HH:MI:SS[.ffffff][+HH:MM]'. A time part is always
present: Teradata rejects TIMESTAMP '2024-03-31' (Error 3706, verified
live), so a bare date becomes midnight. Fractional seconds and a time-zone
offset are kept when given (both verified accepted in VALIDTIME AS OF);
without an offset the literal is read in the session time zone, exactly as
tdfs4ds.FEATURE_STORE_TIME is when features are ingested.
Accepted inputs: ISO strings ('2024-03-31', '2024-03-31 23:59',
'2024-03-31T23:59:59.5Z', '2024-03-31 23:59:59+0200'),
datetime.datetime, datetime.date, pandas.Timestamp and
numpy.datetime64. Anything else — including ambiguous forms such as
'03/31/2024' — raises ValueError naming the accepted formats, rather
than being guessed.
calendar_offset
¶
The offset shared by the dates of a WITH TIME ZONE calendar, else None
(0.3.7.28). One small read; fail-open (None).
has_zone
¶
Whether a timestamp text ends with a UTC offset (+01:00, -0500, Z). Pure.
is_zoned_type
¶
Whether a calendar type carries a time zone (... WITH TIME ZONE). Pure.
literal_with_zone
¶
literal for a calendar of type data_type (0.3.7.28). Pure.
A WITH TIME ZONE calendar given a date with no zone would take the session's zone
(a Central European session stored 2026-11-30 23:00 UTC for 2026-12-01). The
date gets offset (the one the calendar's dates share), else +00:00. A literal that
carries a zone, or another type of calendar, is returned as is.
business_date_literal
¶
The TIMESTAMP literal body a business date reads at (pure).
calendar: a calendar (TimeManager) drives the zone. With no calendar a date
without an offset gets +00:00. With a calendar of a WITH TIME ZONE type it
gets offset (the one its dates share), else +00:00; another type gets none
(the session's zone, like the manager's own scalar). An explicit offset always wins.
_calendar_manager
¶
(TimeManager or None, source): the manager whose zone applies.
_calendar_type
¶
The exact SQL type of the calendar's BUSINESS_DATE (TYPE(), one small read).
TimeManager.data_type keeps teradataml's spelling for a manager rebuilt from its
view (TIMESTAMP for TIMESTAMP(0) WITH TIME ZONE: seen live), which hides the zone.
dataset_spec_at
¶
The dataset's DatasetSpec with its time set to AS OF the business date as_of.
dataset_sql
¶
SQL text of the dataset name at the business date as_of (nothing is executed or created).
as_of is a BUSINESS date: a bare date ('2024-03-31', datetime.date) is read at
midnight in the zone the store's dates are written in (the dataset's TimeManager calendar,
else the domain clock's, else +00:00), NOT in the session's zone as
build_dataset(as_of=...) does. A timestamp with an offset is used as given.
entity: optional key filter, {column: value} (or a list of such dicts), pushed into
every storage-table read.
read_dataset
¶
Rows of the dataset name at the business date as_of: stateless, no view, no cursor moved.
Returns a teradataml DataFrame (lazy), or a pandas frame with as_pandas=True (one
raw statement). See dataset_sql for what a bare date means and entity=. The
TimeManager of a time-driven dataset is NOT moved: the date is a literal in the query.