---
sidebar:
  hidden: true
title: roboto.formats.parquet.timestamp
---
## Module Contents

### Timestamp

```python
class roboto.formats.parquet.timestamp.Timestamp
```

`from roboto.formats.parquet import Timestamp`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L61-L137)

Timestamp field of a Parquet file: the field that holds each row's timestamp, and the unit of its values.

The SDK's own code uses it; to read a topic's data, use [`get_data()`](/docs/reference/python-sdk/roboto/domain/topics/topic#roboto.domain.topics.topic.Topic.get_data) instead. [`extract_timestamp_field()`](/docs/reference/python-sdk/roboto/formats/parquet/table_transforms#roboto.formats.parquet.table_transforms.extract_timestamp_field) builds it, [`should_read_row_group()`](/docs/reference/python-sdk/roboto/formats/parquet/table_transforms#roboto.formats.parquet.table_transforms.should_read_row_group) takes it to skip row groups outside a time range, and [`extract_timestamps()`](/docs/reference/python-sdk/roboto/formats/parquet/table_transforms#roboto.formats.parquet.table_transforms.extract_timestamps) takes it to convert the field's values to nanoseconds since the Unix epoch.

**Attributes**

- **Timestamp.column_index** (`int`): Index of the timestamp's column chunk in every row group: its position among the file's leaf columns.

- **Timestamp.field** (`pyarrow.Field`): Arrow field that holds the timestamp, found at `path` in the file's schema.

- **Timestamp.path** (`tuple[str, ...]`): Names of the fields that lead from the schema's root to the timestamp field, through structs only.

- **Timestamp.unit_hint** (`str | None`): Unit of the stored values, or `None` if it is unknown.

  A [`TimeUnit`](/docs/reference/python-sdk/roboto/time#roboto.time.TimeUnit) value, such as `"ms"`. `unit` reads it when the field's Arrow type carries no unit, as with an integer, decimal or floating-point field. Callers take it from the timestamp message path's [`Unit`](/docs/reference/python-sdk/roboto/domain/topics/record#roboto.domain.topics.record.MessagePathMetadataWellKnown.Unit) metadata, or from `roboto.experimental.topics.ReadPlanTimestamp.unit`.

#### Timestamp.to_epoch_nanoseconds()

```python
def to_epoch_nanoseconds(timestamp: roboto.time.Time) -> int
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L89-L103)

Convert a value of the timestamp field to nanoseconds since the Unix epoch.

A numeric `timestamp` is read as a number of `unit_hint`, even when the field's Arrow type carries its own unit. [`to_epoch_nanoseconds()`](/docs/reference/python-sdk/roboto/time#roboto.time.to_epoch_nanoseconds) does the conversion, and its failures also apply.

**Parameters**

- **timestamp** (`roboto.time.Time`): Value of the timestamp field, such as the minimum or maximum in a row group's statistics.

**Raises**

- `Exception`: `unit_hint` is `None`.
- `NotImplementedError`: `unit_hint` is not a [`TimeUnit`](/docs/reference/python-sdk/roboto/time#roboto.time.TimeUnit) value.

**Returns**

- `int`

#### Timestamp.unit()

```python
def unit() -> roboto.time.TimeUnit
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L105-L120)

Return the unit of the timestamp's values.

The unit comes from the field's Arrow type when it is a timestamp type, and from `unit_hint` otherwise.

**Raises**

- `Exception`: The field's Arrow type is not a timestamp type and `unit_hint` is `None`.
- `NotImplementedError`: The unit is read from `unit_hint`, which is not a [`TimeUnit`](/docs/reference/python-sdk/roboto/time#roboto.time.TimeUnit) value.

**Returns**

- `roboto.time.TimeUnit`

### TimestampInfo

```python
class roboto.formats.parquet.timestamp.TimestampInfo
```

`from roboto.formats.parquet.timestamp import TimestampInfo`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L141-L190)

Timestamp column of a Parquet file being stored as a topic, with its unit and the range of its values.

[`extract_timestamp_info()`](/docs/reference/python-sdk/roboto/formats/parquet/parquet_parser#roboto.formats.parquet.parquet_parser.ParquetParser.extract_timestamp_info) returns it, and [`generate_message_path_requests()`](/docs/reference/python-sdk/roboto/formats/parquet/arrow_to_roboto#roboto.formats.parquet.arrow_to_roboto.generate_message_path_requests) takes it. [`create_from_df()`](/docs/reference/python-sdk/roboto/domain/topics/topic#roboto.domain.topics.topic.Topic.create_from_df) uses both to set a new topic's message paths and time range. Import it from `roboto.formats.parquet.timestamp`.

**Attributes**

- **TimestampInfo.end_time** (`int | float | datetime.datetime | None`): Latest value in the column, in the same form as `start_time`, or `None` if the column holds no values.

- **TimestampInfo.field** (`pyarrow.Field`): Arrow field of the timestamp column.

- **TimestampInfo.start_time** (`int | float | datetime.datetime | None`): Earliest value in the column, or `None` if the column holds no values.

  A `datetime.datetime` or a number of `unit`.

- **TimestampInfo.unit** (`roboto.time.TimeUnit`): Unit of the column's values.

#### TimestampInfo.end_time_ns()

```python
def end_time_ns() -> Optional[int]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L179-L190)

Return `end_time` in nanoseconds since the Unix epoch, or `None` if it is `None`.

It is converted the same way as by `start_time_ns`.

**Returns**

- `Optional[int]`

#### TimestampInfo.start_time_ns()

```python
def start_time_ns() -> Optional[int]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L165-L177)

Return `start_time` in nanoseconds since the Unix epoch, or `None` if it is `None`.

A `datetime.datetime` is converted through a floating-point number of seconds, so the result can be off by a few hundred nanoseconds. A fraction of a nanosecond is dropped.

**Returns**

- `Optional[int]`

### is_timestamp_like()

```python
def roboto.formats.parquet.timestamp.is_timestamp_like(
    arrow_type: pyarrow.DataType,
) -> bool
```

`from roboto.formats.parquet.timestamp import is_timestamp_like`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L22-L37)

Return whether `arrow_type` can hold a timestamp: a timestamp, integer, decimal or floating-point type.

**Parameters**

- **arrow_type** (`pyarrow.DataType`): Arrow type to check.

**Returns**

- `bool`

### is_timezone_aware()

```python
def roboto.formats.parquet.timestamp.is_timezone_aware(
    arrow_type: pyarrow.DataType,
) -> bool
```

`from roboto.formats.parquet.timestamp import is_timezone_aware`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L40-L48)

Return whether `arrow_type` is an Arrow timestamp type with a time zone.

**Parameters**

- **arrow_type** (`pyarrow.DataType`): Arrow type to check.

**Returns**

- `bool`

### time_unit_from_timestamp_type()

```python
def roboto.formats.parquet.timestamp.time_unit_from_timestamp_type(
    timestamp_type: pyarrow.TimestampType,
) -> roboto.time.TimeUnit
```

`from roboto.formats.parquet.timestamp import time_unit_from_timestamp_type`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/parquet/timestamp.py#L51-L57)

Return the unit an Arrow timestamp type records its values in.

**Parameters**

- **timestamp_type** (`pyarrow.TimestampType`): Arrow timestamp type to read the unit of.

**Returns**

- `roboto.time.TimeUnit`
