Bug Description:
When writing a SQLMesh unit test that includes a TIMESTAMP column with the value 0001-01-01 00:00:00, the test runner throws the following warnings and fails to compare the expected and actual values correctly.
[WARNING] Failed to convert expected value for timestamp_field
into datetime for unit test 'test_model'
(tests\test_model.yaml)'.
Out of bounds nanosecond timestamp: 0001-01-01 00:00:00, at position 0.
The value 0001-01-01 00:00:00 is a valid SQL TIMESTAMP but falls outside the range that pandas can handle with nanosecond precision (which starts at 1677-09-21).
Steps to Reproduce:
- Create a model with a TIMESTAMP column that can contain '0001-01-01 00:00:00'.
- Write a unit test with that value in the expected output
- Run SQLMesh test
Expected Behaviour:
The test should either:
Successfully compare the timestamp values, or
Provide a clear error message with a suggested workaround
Actual Behaviour:
The test throws a 'Failed to convert expected value into datetime' warning, and the comparison fails.
Attempted Workarounds:
The following workarounds were attempted but did not resolve the issue:
- Specifying the column type as VARCHAR in the columns attribute of the test
- Using a SQL query format for the expected output with explicit CAST
- Using explicit CAST('0001-01-01 00:00:00' AS VARCHAR) in the output query
- Adding column_definitions to the model.
Environment:
SQLMesh version: 0.227.1
Database dialect: Redshift
Bug Description:
When writing a SQLMesh unit test that includes a TIMESTAMP column with the value 0001-01-01 00:00:00, the test runner throws the following warnings and fails to compare the expected and actual values correctly.
[WARNING] Failed to convert expected value for timestamp_field
into datetime for unit test 'test_model'
(tests\test_model.yaml)'.
Out of bounds nanosecond timestamp: 0001-01-01 00:00:00, at position 0.
The value 0001-01-01 00:00:00 is a valid SQL TIMESTAMP but falls outside the range that pandas can handle with nanosecond precision (which starts at 1677-09-21).
Steps to Reproduce:
Expected Behaviour:
The test should either:
Successfully compare the timestamp values, or
Provide a clear error message with a suggested workaround
Actual Behaviour:
The test throws a 'Failed to convert expected value into datetime' warning, and the comparison fails.
Attempted Workarounds:
The following workarounds were attempted but did not resolve the issue:
Environment:
SQLMesh version: 0.227.1
Database dialect: Redshift