Class - mitto.iov2.steps.builtin.MaxTimestamp

JSON Schema

MaxTimestamp

Obtain the maximum value of a timestamp column from the output databse. Place the value, known as the timestamp, in the job’s execution environment so that subsequent steps in the job can later reference the timestamp value. Most often used in conjunction with SetUpdatedAt in upsert jobs.

Timestamp values may be int, float, and Decimal Python types. These are useful in conjunction with a column that autoincrements as rows are added to a table. The timestamp’s value is placed in the job’s environment as-is (e.g., as a Python int).

Timestamp values may also be a datetime.datetime Python type. Python datetime objects are classified as either aware (tz-aware) or naive (tz-unaware), depending upon whether or not they include timezone information. Such timestamp values are formatted as a string using datetime.isoformat() and the string is placed in the job’s environment.

For more inforation on timezones, see: https://docs.python.org/3/library/datetime.html#aware-and-naive-objects

TIMEZONE MANIPULATION

MaxTimestamp provides parameters that can be used when modifying a timestamp’s timezone to make the value compatible with your use-case. Timezones can be manipulated in the following ways:

  1. int, float, and Decimal timestamp values are returned unmodified, regardless of the value of tz_default and tz_aware. These types do not support the notion of timezones.

  2. datetime.datetime timestamp values may be modified according to the following:

    1. If tz_aware is true

      1. If the timestamp value is tz-aware, the value is returned without modification.

      2. If the timestamp value is tz-unaware, the value is modified by adding the timezone specified by tz_default. E.g.: If tz_default=”America/Chicago”, an initial timestamp value of datetime(2024, 1, 1, 13, 34, 56) would become datetime(2024, 1, 1, 13, 34, 56, tzinfo=<DstTzInfo ‘America/Chicago’ CST-1 day, 18:00:00 STD>).

    2. If tz_aware is false

      1. If the timestamp value is tz-unaware, the value is returned without modification.

      1. If the timestamp value is tz-aware, the value is is converted to a tz-unaware timestamp by removing the timezone information. This is useful when working with with tz-unaware column types.

type

object

properties

  • environ

Environ

The job’s runtime execution environment. Do not provide this value in a job config; it is automatically provided by Runner.

  • logger

Logger

The Runner logger to use for log messages. Do not provide this value in a job config; it is automatically provided by Runner.

  • column

Column

Name of column containing the timesamp values to query.

type

string

  • delta

Delta

A time delta to be subtracted from the timestamp that is obtained from the table. The value is a dict which is passed as parameters to the Python datetime.timedelta function.

type

object

examples

{“days”: 1}

{“hours”: -10, “minutes”: -30}

  • tablename

Tablename

The table containing the timestamp column to query. Defaults to the tablename in the job’s execution environment, which is usually defined in the dbo of the job’s output step.

type

string

  • schema

Schema

The schema containing the table to query. Defaults to the schema defined in the dbo of the output step.

type

string

  • params

Params

Dict containing additional criteria that will be applied to limit records queried for the timestamp.

type

object

examples

{“region”: “USA”}

default

  • tz_default

Tz Default

The timezone applied to a tz-unaware timestamp. Unused if timestamp is already tz-aware. The string value must be one of the IANA timezones provided by the Python zoneinfo package. https://docs.python.org/3/library/zoneinfo.html If an invalid timezone is provided, ‘UTC’ will be used instead.

type

string

examples

“America/Chicago”

“US/Eastern”

“Australia/Melbourne”

default

UTC

  • tz_aware

Tz Aware

If true, ensure that timestamp is tz-aware, adding the timezone (specified by tz_default) to timestamp, if necessary.

type

boolean

examples

false

default

True