Aligning date32 contracts across Python lists and NumPy arrays
Record the date unit and the supported conversion path alongside the integer values.
Separate date meaning from conversion support
Specify both the integer-date unit contract and the conversion path supported by the input container. Integer 1 needs an epoch and unit before it denotes a date. An error after changing containers must not be reinterpreted as an empty dataset. [1, 2, 3]
A successful list and a rejected NumPy array
The PyArrow 26.0.0 and NumPy 2.5.4 report converts list [0, 1, 2] to date32 values from January 1 through January 3, 1970. The equivalent NumPy array raises an unsupported int64-to-date32 cast error. This establishes a difference between input paths, rather than demonstrating that the integer values themselves are invalid. [1]
Make the conversion boundary explicit
Document the epoch and day unit, compare explicit container-specific conversion paths, and never replace a failed array with an empty table. Retain container_kind and integer_day and compare successful outputs in one ISO-date form. Seconds or milliseconds misread as days can produce incorrect dates even through a supported path. [1, 3]
A control for the day after the epoch
Define an illustrative contract where 0 denotes 1970-01-01 and 1 denotes the next day. For input 1, 1970-01-02 passes and 1970-01-01 fails. Truthound Core's ColumnPairValidator can compare successfully converted ISO dates with independently prepared references. It does not add unsupported Arrow casts or recover a failed conversion. Keep conversion failure status separate from value comparison and attached to the original request. [1, 2, 3]
Application conditions
Prepare container_kind, integer_day, expected_iso_date and converted_iso_date from original data or an independent reference, aligned to the same run, file and key scope.
Alternatives
Perform an explicit date conversion appropriate to the input container first.
Limitations
Truthound does not add unsupported Arrow casts. Do not interpret integers measured in seconds or milliseconds under a date32 day contract.
Evidence
- Event checked
- Subject checked
- Modified
