scruz-denodo commented on code in PR #43149:
URL: https://github.com/apache/arrow/pull/43149#discussion_r1689253658
##########
java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/calendar/ArrowFlightJdbcDateVectorAccessor.java:
##########
@@ -108,11 +104,36 @@ private void fillHolder() {
@Override
public Timestamp getTimestamp(Calendar calendar) {
- Date date = getDate(calendar);
- if (date == null) {
+ final LocalDateTime localDateTime = getLocalDateTime(calendar);
+ if (localDateTime == null) {
+ return null;
+ }
+
+ return Timestamp.valueOf(localDateTime);
+ }
+
+ private LocalDateTime getLocalDateTime(Calendar calendar) {
+ getter.get(getCurrentRow(), holder);
+ this.wasNull = holder.isSet == 0;
+ this.wasNullConsumer.setWasNull(this.wasNull);
+ if (this.wasNull) {
return null;
}
- return new Timestamp(date.getTime());
+
+ final LocalDateTime localDateTime =
+
DateUtility.getLocalDateTimeFromEpochMilli(this.timeUnit.toMillis(holder.value));
+ final ZoneId defaultTimeZone =
Calendar.getInstance().getTimeZone().toZoneId();
Review Comment:
Hi, I will be out for a few days. I will try to answer questions when I
return.
In the meantime, I would like to comment:
> Yeesh, system timezone appears to be a convention (e.g. [this
StackOverflow
answer](https://stackoverflow.com/questions/9202857/timezones-in-sql-date-vs-java-sql-date))
but doesn't appear to be formally specified. I still think that, given Arrow
actually specifies the epoch for its values, introducing the system timezone
merely to be consistent with databases that appear not to store this
information is strictly wrong.
It is true that documentation is not 100% clear, but it is also true that
other JDBC drivers from important vendors work like that, using the default JVM
timezone. So, a generic JDBC client will expect the data on that way.
> I'm talking about Date here still.
(1) Arrow's Date is defined in terms of the Unix epoch (i.e. UTC), and (2)
java.sql.Date is also defined in terms of GMT. So it doesn't seem like the
system timezone should be relevant.
I will check again the code. But the problem is the same. The
`java.sql.Date` has also hours, minutes and seconds. So, the Arrow JDBC driver
retrieves the value in UTC, ok, but when a new `Date` is created it is done on
the default JVM timezone. So, it can generate a different date than the
expected. This is why a similar translation than the applied with `Timestamp`
is required.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]