[Fix][Connector-v2] Add DateMilliConvertor to Convert DateMilliVector into Default Timezone#8736
Conversation
Hisoka-X
left a comment
There was a problem hiding this comment.
Could you add a test case to cover it?
There is already this test case: |
I think we can use a fixed datetime (not use system time now()) to reproduce this bug. |
Any test case failed link? |
No, I discovered this during local debugging. This test case is likely to reproduce the issue if run before 8 a.m. |
|
OK, please add test case. |
Ok, I will refer to this to add the test case. @Hisoka-X |
| * on windows The test case uses TimeStampMicroVector to test the timestamp, thus truncating the | ||
| * timestamp accuracy to ChronoUnit.MILLIS | ||
| */ | ||
| private static final LocalDateTime localDateTime = |
There was a problem hiding this comment.
| private static final LocalDateTime localDateTime = | |
| private static final LocalDateTime localDateTime = | |
| LocalDateTime.parse( | |
| "2025-02-15 02:21:23", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| @@ -172,13 +178,7 @@ private static VectorSchemaRoot buildVectorSchemaRoot( | |||
| } | |||
| // allocate storage | |||
| vectors.forEach(FieldVector::allocateNew); | |||
There was a problem hiding this comment.
| vectors.forEach(FieldVector::allocateNew); | |
| vectors.forEach(FieldVector::allocateNew); | |
| long epochMilli = localDateTime.atZone(zoneId).toInstant().toEpochMilli(); |
| .setSafe(i, (stringValue).getBytes(StandardCharsets.UTF_8)); | ||
| } else if (vector instanceof TimeStampMicroVector) { | ||
| ((TimeStampMicroVector) vector).setSafe(i, epochMilli * 1000); | ||
| ((TimeStampMicroVector) vector).setSafe(i, testEpochMilli); |
There was a problem hiding this comment.
| ((TimeStampMicroVector) vector).setSafe(i, testEpochMilli); | |
| ((TimeStampMicroVector) vector).setSafe(i, epochMilli * 1000); |
| .setSafe(i, (stringValue).getBytes(StandardCharsets.UTF_8)); | ||
| } else if (vector instanceof TimeStampMilliTZVector) { | ||
| ((TimeStampMilliTZVector) vector).setSafe(i, epochMilli); | ||
| ((TimeStampMilliTZVector) vector).setSafe(i, testEpochMilli); |
There was a problem hiding this comment.
| ((TimeStampMilliTZVector) vector).setSafe(i, testEpochMilli); | |
| ((TimeStampMilliTZVector) vector).setSafe(i, epochMilli); |
| ((TimeStampMilliTZVector) vector).setSafe(i, testEpochMilli); | ||
| } else if (vector instanceof TimeMicroVector) { | ||
| ((TimeMicroVector) vector).setSafe(i, epochMilli); | ||
| ((TimeMicroVector) vector).setSafe(i, testEpochMilli); |
| ((TimeMicroVector) vector).setSafe(i, testEpochMilli); | ||
| } else if (vector instanceof DateMilliVector) { | ||
| ((DateMilliVector) vector).setSafe(i, epochMilli); | ||
| ((DateMilliVector) vector).setSafe(i, testEpochMilli); |
| List<LocalDateTime> dateTimeList = new ArrayList<>(); | ||
| for (int j = 0; j < 5; j++) { | ||
| writer.writeTimeStampMilliTZ(epochMilli); | ||
| writer.writeTimeStampMilliTZ(testEpochMilli); |
hawk9821
left a comment
There was a problem hiding this comment.
LGTM. Thanks @xiaochen-zhou
… into Default Timezone (apache#8736)




Purpose of this pull request
Does this PR introduce any user-facing change?
The DateMilliVector type in Apache Arrow stores timestamps in UTC,Add DateMilliConvertor to Convert DateMilliVector into Default Timezone.
How was this patch tested?
exist tests
Check list
New License Guide
release-note.