-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Fix][Connector-v2] Add DateMilliConvertor to Convert DateMilliVector into Default Timezone #8736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hisoka-X
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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")); |
| // map | ||
| } | ||
| // allocate storage | ||
| vectors.forEach(FieldVector::allocateNew); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ((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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ((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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| ((TimeMicroVector) vector).setSafe(i, testEpochMilli); | ||
| } else if (vector instanceof DateMilliVector) { | ||
| ((DateMilliVector) vector).setSafe(i, epochMilli); | ||
| ((DateMilliVector) vector).setSafe(i, testEpochMilli); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| List<LocalDateTime> dateTimeList = new ArrayList<>(); | ||
| for (int j = 0; j < 5; j++) { | ||
| writer.writeTimeStampMilliTZ(epochMilli); | ||
| writer.writeTimeStampMilliTZ(testEpochMilli); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
hawk9821
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.