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

JDBC adapter generates incorrect SQL to implement FLOOR(dateTime to HOUR) on MySQL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.14.0
    • 1.17.0
    • jdbc-adapter
    • MySQL 5.6.34
      mysql-connector-java.jar:5.1.39
      Calcite 1.14.0-SNAPSHOT

    Description

      I execute the sql "select FLOOR(trade_time TO HOUR) ..."
      then I get the ResultSet, if time hour is less than 10, I get the following exception:

      java.lang.RuntimeException: java.sql.SQLException: Bad format for Timestamp '2017-06-30 7:00:00' in column 1.
      
      	at Baz$1$1.apply(Unknown Source)
      	at org.apache.calcite.runtime.ResultSetEnumerable$ResultSetEnumerator.current(ResultSetEnumerable.java:187)
      	at org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:672)
      	at org.apache.calcite.avatica.util.IteratorCursor.next(IteratorCursor.java:46)
      	at org.apache.calcite.avatica.AvaticaResultSet.next(AvaticaResultSet.java:239)
      	at TestCalcite.test028_jdbc(TestCalcite.java:75)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runners.Suite.runChild(Suite.java:128)
      	at org.junit.runners.Suite.runChild(Suite.java:27)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: java.sql.SQLException: Bad format for Timestamp '2017-06-30 7:00:00' in column 1.
      	at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1157)
      	at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:130)
      	at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:5946)
      	at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:5616)
      	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:250)
      	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:250)
      	... 36 more
      

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            wkang Kang Wang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified