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

Query fails when comparing Time/TimeStamp types

    XMLWordPrintableJSON

    Details

      Description

      A similar test like ReflectiveSchemaTest#testDateCanCompare

      @Test public void testDateCanCompare2() {
        final String sql = "select a.v1, a.v2\n"
            + "from (select \"sqlTime\" v1, \"sqlTimestamp\" v2\n"
            + "  from \"s\".\"everyTypes\" "
            + "  group by \"sqlTime\", \"sqlTimestamp\") a,"
            + "    (select \"sqlTime\" v1, \"sqlTimestamp\" v2\n"
            + "  from \"s\".\"everyTypes\"\n"
            + "  group by \"sqlTime\", \"sqlTimestamp\") b\n"
            + "where a.v1 >= b.v1 and a.v2 >= b.v2\n"
            + "group by a.v1, a.v2";
        CalciteAssert.that()
            .withSchema("s", CATCHALL)
            .query(sql)
            .returnsUnordered("V1=00:00:00; V2=1970-01-01 00:00:00");
      }

      The query fails with exception:

      Caused by: java.lang.ClassCastException: java.sql.Time cannot be cast to java.lang.Integer
       at Baz$10$1.moveNext(Unknown Source)
       at org.apache.calcite.linq4j.EnumerableDefaults.groupBy_(EnumerableDefaults.java:825)
       at org.apache.calcite.linq4j.EnumerableDefaults.groupBy(EnumerableDefaults.java:764)
       at org.apache.calcite.linq4j.DefaultEnumerable.groupBy(DefaultEnumerable.java:308)
       at Baz.bind(Unknown Source)

      We also need to support type cast from Time/TimeStamp to Integer/Long

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                donnyzone Feng Zhu
                Reporter:
                donnyzone Feng Zhu
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h 50m
                  5h 50m