[ 
https://issues.apache.org/jira/browse/CALCITE-4120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17627829#comment-17627829
 ] 

Ian Bertolacci commented on CALCITE-4120:
-----------------------------------------

I tried that, and with JdbcMeta using the UTC calendar, the same test starts 
failing immediately.
In this case it is because the UTC Timestamp values of the test are interpreted 
as Timestamp values in the AvaticaPreparedStatement's calendar time (which is a 
calendar with local time-zone, with no way to override that behavior), so the 
get incorrectly translated to UTC (which in my case offsets them by 8 hours).

If this is the correct behavior, then it seems very asymmetrical, since the 
client would have to form local time-zone Timestamp values, but then expect 
that what comes out of the server is UTC Timestamp values, and convert them 
back to the local time-zone.

It would make sense to me if it was all one way or the other (ie. timestamps go 
in and come out with the same timestamp value).

> Inconsistent Calendar used In JdbcMeta between prepareAndExecute and Fetch
> --------------------------------------------------------------------------
>
>                 Key: CALCITE-4120
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4120
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Chris Snowden
>            Priority: Major
>
> org.apache.calcite.avatica.jdbc.JdbcMeta prepareAndExecute is using UTC 
> calendar but fetch is using local calendar, results in inconsistent TZs being 
> applied for single statement. 
> [https://github.com/apache/calcite-avatica/blob/master/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java]
> [https://github.com/apache/calcite-avatica/blob/master/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java]
>  
> {code:java}
> org.apache.calcite.avatica.jdbc.JdbcMeta 
> final Calendar calendar = Unsafe.localCalendar(); //LOCAL
> public ExecuteResult prepareAndExecute(
>     StatementHandle h, 
>     String sql, 
>     long maxRowCount, 
>     int maxRowsInFirstFrame, 
>     PrepareCallback callback) throws NoSuchStatementException {
> ....
>     resultSets.add(JdbcResultSet.create(h.connectionId, h.id, 
> info.getResultSet(), maxRowsInFirstFrame)); //USES UTC CALENDAR      
> ....
> }
> public Frame fetch(
>     StatementHandle h, 
>     long offset, 
>     int fetchMaxRowCount) throws NoSuchStatementException, 
> MissingResultsException {
> ...
>     return JdbcResultSet.frame(statementInfo, statementInfo.getResultSet(), 
> offset, fetchMaxRowCount, calendar, Optional.<Meta.Signature>absent()); 
> //USES LOCAL CALENDAR
> ...
> }
> ____________________________________________________________________
> org.apache.calcite.avatica.jdbc.JdbcResultSet
> public static JdbcResultSet create(
>     String connectionId, 
>     int statementId,      
>     ResultSet resultSet, 
>     int maxRowCount, 
>     Meta.Signature signature) {
>     final Calendar calendar = DateTimeUtils.calendar(); //UTC
>     ....
>     final Meta.Frame firstFrame = frame(null, resultSet, 0, fetchRowCount, 
> calendar, Optional.of(signature))
>     ....
> }
> {code}
>  
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to