Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4120

Inconsistent Calendar used In JdbcMeta between prepareAndExecute and Fetch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      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

       

      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))
          ....
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              cpsnowden Chris Snowden
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: