Commit d9c3820
committed
fix(test): support out-of-nanosecond-range timestamps in unit test comparisons
When a database engine (e.g. Redshift) returns a TIMESTAMP column as an
object-dtype series of python `datetime.datetime` instances, the unit
test comparison path parses the YAML-supplied expected values with
`pd.to_datetime`, which defaults to nanosecond resolution and overflows
outside 1677-09-21..2262-04-11. Values that SQL TIMESTAMP fully supports
(e.g. `0001-01-01 00:00:00`) triggered a `Failed to convert expected
value into datetime` warning and either a false mismatch or, when the
values happened to round-trip cleanly through `str()`, a silent one.
Fall back to `datetime64[us]` on `OutOfBoundsDatetime` so the comparison
sees equivalent python datetime objects and succeeds. Microsecond
resolution covers year 1 through year 294246, matching SQL TIMESTAMP.
Fixes #5929
Signed-off-by: mokashang <shangmengjiajiajia@gmail.com>1 parent b2fa0a6 commit d9c3820
2 files changed
Lines changed: 67 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
272 | 269 | | |
273 | 270 | | |
274 | 271 | | |
| |||
1014 | 1011 | | |
1015 | 1012 | | |
1016 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1017 | 1038 | | |
1018 | 1039 | | |
1019 | 1040 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2931 | 2931 | | |
2932 | 2932 | | |
2933 | 2933 | | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
2934 | 2974 | | |
2935 | 2975 | | |
2936 | 2976 | | |
| |||
0 commit comments