apache / apache/arrow-java

[Java] getObject API for temporal types is inconsistent and in some cases incorrect

未關閉
#324 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Type: bug
主要語言
Java
星號
94
分支
152
平均合併
3 天 16 小時
30 天內合併 PR
11

描述

It seems that the work which has been tracked in ARROW-2015 and merged in to change the return types of the various Time and Date vector types when using the getObject API missed some of the vector types which are temporal and so should return a temporal type, and provided an incorrect implementation for others (some of this was pointed out in the initial PR review, but it seems that it slipped through the cracks and was not addressed before merging).

Here is a table of the various temporal vector types, what they currently return from getObject, and what they should return, in my opinion (I have included ones in which the implementation is correct for completeness, and coloured them green).

 

 

|Vector class|Current return type|Proposed return type|Comments|
|
|-|-|-|-|-|
|DateDayVector|Integer|LocalDate|Currently returns the raw value of days since epoch, should return the actual date|
|
|DateMilliVector|LocalDateTime|LocalDate|This type is supposed to encode a date, not a datetime, so even though epoch millis are used, the result should be a LocalDate|
|
|DurationVector|Duration|Duration|Correct.|
|
|IntervalDayVector|Duration|Period|As per , Interval should be a calendar-based datatype, not a time-based one. This is represented in Java by a Period type. However, I note that the Java Period class does not support milliseconds, unlike the Arrow type, which might be why Duration is being returned. Some discussion may be needed on the best way to deal with this.|
|
|IntervalYearVector|Period|Period|Correct.|
|
|TimeMicroVector|Long|LocalTime|Currently returns the raw number of micros, should return the actual time|
|
|TimeMilliVector|LocalDateTime|LocalTime|Currently returns a datetime on 1970-01-01 with the correct time component, should just return the time|
|
|TimeNanoVector|Long|LocalTime|Currently returns the raw number of nanos, should return the actual time|
|
|TimeSecVector|Integer|LocalTime|Currently returns the raw number of seconds, should return the actual time|
|
|TimeStampMicroVector|LocalDateTime|LocalDateTime|Correct.|
|
|TimeStampMilliVector|LocalDateTime|LocalDateTime|Correct.|
|
|TimeStampNanoVector|LocalDateTime|LocalDateTime|Correct.|
|
|TimeStampSecVector|LocalDateTime|LocalDateTime|Correct.|
|
|TimeStampMicroTZVector|Long|ZonedDateTime|Currently returns the underlying micros, and TZ has to be obtained separately. Should return the actual datetime with timezone|
|
|TimeStampMilliTZVector|Long|ZonedDateTime|Currently returns the underlying millis, and TZ has to be obtained separately. Should return the actual datetime with timezone|
|
|TimeStampNanoTZVector|Long|ZonedDateTime|Currently returns the underlying nanos, and TZ has to be obtained separately. Should return the actual datetime with timezone|
|
|TimeStampSecTZVector|Long|ZonedDateTime|Currently returns the underlying seconds, and TZ has to be obtained separately. Should return the actual datetime with timezone|



I am happy to submit a PR to fix this if there is no other reason for this to persist other than these types being rarely used, but note that these would all be breaking API changes.



 |

**Reporter**: [Matt Jadczak](https://issues.apache.org/jira/browse/ARROW-9915)

**Note**: *This issue was originally created as [ARROW-9915](https://issues.apache.org/jira/browse/ARROW-9915). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

貢獻指南

開啟貢獻指南

研究方向

首先定位所列時間向量類別的 getObject 實作,並檢視 ARROW-2015 和 pull request 2966 中的變更。在決定 Java 回傳型別之前,檢查 Arrow interval schema,尤其是 IntervalDayVector 的毫秒表示。完成的標準是:受影響的向量一致地回傳所提議的時間型別,且每個已變更的 mapping 都有涵蓋。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
api
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。