|
28 | 28 | #include <functional> |
29 | 29 | #include <set> |
30 | 30 | #include <sstream> |
| 31 | +#include <utility> |
31 | 32 | #include <vector> |
32 | 33 |
|
33 | 34 | #include "arrow/array/builder_binary.h" |
|
74 | 75 | #include "parquet/page_index.h" |
75 | 76 | #include "parquet/properties.h" |
76 | 77 | #include "parquet/test_util.h" |
| 78 | +#include "parquet/types.h" |
77 | 79 |
|
78 | 80 | using arrow::Array; |
79 | 81 | using arrow::ArrayData; |
@@ -4149,14 +4151,29 @@ INSTANTIATE_TEST_SUITE_P(Repetition_type, TestNestedSchemaRead, |
4149 | 4151 | ::testing::Values(Repetition::REQUIRED, Repetition::OPTIONAL)); |
4150 | 4152 |
|
4151 | 4153 | TEST(TestImpalaConversion, ArrowTimestampToImpalaTimestamp) { |
4152 | | - // June 20, 2017 16:32:56 and 123456789 nanoseconds |
4153 | | - int64_t nanoseconds = INT64_C(1497976376123456789); |
| 4154 | + std::vector<std::pair<int64_t, Int96>> test_cases = { |
| 4155 | + // June 20, 2017 16:32:56 and 123456789 nanoseconds |
| 4156 | + {INT64_C(1497976376123456789), |
| 4157 | + {{UINT32_C(632093973), UINT32_C(13871), UINT32_C(2457925)}}}, |
| 4158 | + // January 1, 1970 00:00:00 and 000000000 nanoseconds |
| 4159 | + {INT64_C(0), {{UINT32_C(0), UINT32_C(0), UINT32_C(2440588)}}}, |
| 4160 | + // December 31, 1969 23:59:59 and 999999000 nanoseconds |
| 4161 | + {INT64_C(-1000), {{UINT32_C(2437872664), UINT32_C(20116), UINT32_C(2440587)}}}, |
| 4162 | + // December 31, 1969 00:00:00 and 000000000 nanoseconds |
| 4163 | + {INT64_C(-86400000000000), {{UINT32_C(0), UINT32_C(0), UINT32_C(2440587)}}}, |
| 4164 | + // January 1, 1970 00:00:00 and 000001000 nanoseconds |
| 4165 | + {INT64_C(1000), {{UINT32_C(1000), UINT32_C(0), UINT32_C(2440588)}}}, |
| 4166 | + // January 2, 1970 00:00:00 and 000000000 nanoseconds |
| 4167 | + {INT64_C(86400000000000), {{UINT32_C(0), UINT32_C(0), UINT32_C(2440589)}}}, |
| 4168 | + }; |
4154 | 4169 |
|
4155 | | - Int96 calculated; |
| 4170 | + for (auto& [timestamp, impala_timestamp] : test_cases) { |
| 4171 | + ASSERT_EQ(timestamp, ::parquet::Int96GetNanoSeconds(impala_timestamp)); |
4156 | 4172 |
|
4157 | | - Int96 expected = {{UINT32_C(632093973), UINT32_C(13871), UINT32_C(2457925)}}; |
4158 | | - ::parquet::internal::NanosecondsToImpalaTimestamp(nanoseconds, &calculated); |
4159 | | - ASSERT_EQ(expected, calculated); |
| 4173 | + Int96 calculated; |
| 4174 | + ::parquet::internal::NanosecondsToImpalaTimestamp(timestamp, &calculated); |
| 4175 | + ASSERT_EQ(impala_timestamp, calculated); |
| 4176 | + } |
4160 | 4177 | } |
4161 | 4178 |
|
4162 | 4179 | void TryReadDataFile(const std::string& path, |
|
0 commit comments