You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2023/02/17 02:32:15 UTC

[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4326: [ARROW] Fix Spark session timezone format in arrow-based result format

pan3793 commented on code in PR #4326:
URL: https://github.com/apache/kyuubi/pull/4326#discussion_r1109222045


##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/arrow/ArrowColumnarBatchRow.java:
##########
@@ -131,17 +136,24 @@ public Object get(int ordinal, TTypeId dataType) {
       case STRING_TYPE:
         return getString(ordinal);
       case TIMESTAMP_TYPE:
-        microseconds = getLong(ordinal);
-        nanos = (int) (microseconds % 1000000) * 1000;
-        Timestamp timestamp = new Timestamp(microseconds / 1000);
-        timestamp.setNanos(nanos);
-        return timestamp;
+        if (timestampAsString) {
+          return Timestamp.valueOf(getString(ordinal));
+        } else {
+          LocalDateTime localDateTime =
+              DateUtility.getLocalDateTimeFromEpochMicro(getLong(ordinal), timeZone);
+          long millis = TimeUnit.MICROSECONDS.toMillis(getLong(ordinal));
+          TimeZone zone = TimeZone.getTimeZone(timeZone);
+          localDateTime =
+              localDateTime.minus(
+                  zone.getOffset(millis) - zone.getOffset(millis), ChronoUnit.MILLIS);

Review Comment:
   `zone.getOffset(millis) - zone.getOffset(millis)`?



-- 
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: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org