lidavidm commented on code in PR #35139:
URL: https://github.com/apache/arrow/pull/35139#discussion_r1167835234


##########
java/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/accessor/impl/text/ArrowFlightJdbcVarCharVectorAccessorTest.java:
##########
@@ -510,14 +510,23 @@ public void 
testShouldGetDateReturnValidDateWithCalendar() throws Exception {
     Text value = new Text("2021-07-02");
     when(getter.get(0)).thenReturn(value.copyBytes());
 
-    Calendar calendar = 
Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
-    Date result = accessor.getDate(calendar);
+    {
+      Calendar calendar = 
Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
+      Date result = accessor.getDate(calendar);
+      calendar.setTime(result);
 
-    calendar = Calendar.getInstance(TimeZone.getTimeZone("Etc/UTC"));
-    calendar.setTime(result);
+      collector.checkThat(dateTimeFormat.format(calendar.getTime()),
+          equalTo("2021-07-01T21:00:00.000Z"));

Review Comment:
   Fair, though arguably this is replacing buggy behavior with buggy behavior 🙂 
   
   Let's put a caveat in the documentation page for the driver? 
   
   We should consider aligning with what Derby appears to do, too. Either that, 
or check a few other drivers to see the expected behavior here.
   
   I'm still not sure the conversion here is correct, though. From the docs, 
java.sql.Date is the millisecond value (in GMT) of midnight of a date in some 
time zone. 
   
   So if we have the date "2021-07-02" in America/Sao_Paulo, then the GMT 
timestamp [should be 2021-07-02 
03:00](https://www.wolframalpha.com/input?i=2021-07-02+00%3A00+Sao+Paulo+in+GMT).
 So the new behavior doesn't seem correct and the old behavior is what's 
expected.
   
   Or if we are assuming that the date is "2021-07-02" in UTC, and converting 
that to Sao Paulo, that makes no sense - Date isn't supposed to store a time, 
so we shouldn't treat it as one.



-- 
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]

Reply via email to