Skip to content

Conversation

@xiaochen-zhou
Copy link
Contributor

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

@xiaochen-zhou xiaochen-zhou changed the title [Fix][Zeta] Add DateMilliConvertor to Convert DateMilliVector into Default Timezone [Fix][Connector-v2] Add DateMilliConvertor to Convert DateMilliVector into Default Timezone Feb 14, 2025
Copy link
Member

@Hisoka-X Hisoka-X left a 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?

@xiaochen-zhou
Copy link
Contributor Author

Could you add a test case to cover it?

There is already this test case: ArrowToSeatunnelRowReaderTest#testSeatunnelRow(). If this conversion is not added, it may cause this test case to fail, for example, before 8 a.m.

@xiaochen-zhou
Copy link
Contributor Author

Could you add a test case to cover it?

Store Timestamp:1739564483396
image

image

@Hisoka-X
Copy link
Member

Could you add a test case to cover it?

There is already this test case: ArrowToSeatunnelRowReaderTest#testSeatunnelRow(). If this conversion is not added, it may cause this test case to fail, for example, before 8 a.m.

I think we can use a fixed datetime (not use system time now()) to reproduce this bug.

@Hisoka-X
Copy link
Member

If this conversion is not added, it may cause this test case to fail, for example, before 8 a.m.

Any test case failed link?

@xiaochen-zhou
Copy link
Contributor Author

If this conversion is not added, it may cause this test case to fail, for example, before 8 a.m.

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.

@xiaochen-zhou
Copy link
Contributor Author

Could you add a test case to cover it?

Store Timestamp:1739564483396 image

image

@Hisoka-X

@Hisoka-X
Copy link
Member

If this conversion is not added, it may cause this test case to fail, for example, before 8 a.m.

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.

@xiaochen-zhou
Copy link
Contributor Author

Could you add a test case to cover it?

There is already this test case: ArrowToSeatunnelRowReaderTest#testSeatunnelRow(). If this conversion is not added, it may cause this test case to fail, for example, before 8 a.m.

I think we can use a fixed datetime (not use system time now()) to reproduce this bug.

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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
((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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
((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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@xiaochen-zhou
Copy link
Contributor Author

@Hisoka-X @hawk9821 done.

@Hisoka-X Hisoka-X requested a review from hawk9821 February 18, 2025 06:09
Copy link
Contributor

@hawk9821 hawk9821 left a 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

@hailin0 hailin0 merged commit 7b8298a into apache:dev Feb 18, 2025
3 checks passed
@xiaochen-zhou xiaochen-zhou deleted the arrow_localdatetime branch February 22, 2025 16:53
zax1314157 pushed a commit to zax1314157/seatunnel that referenced this pull request Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants