Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      I was able to install and test out the latest version of optiq and mongodb using the test zips model you have, and even managed to test direct JDBC access programatically and through Quantum DB in eclipse. I setup a basic mapping for my own schema and simple queries seemed to work. However, I've hit a snag while mapping a Date column/property.

      While testing from SQLine I'm getting a java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.Integer.

      I'm using Spring Data's Mongo driver to persist data, and it seems the Date property is recognized as type java.util.Date and JSON encoded properly as ISODate.

      {
      "_id" : ObjectId("53655599e4b0c980df0a8c27"),
      "_class" : "com.ericblue.Test",
      "date" : ISODate("2012-09-05T07:00:00Z"),
      "value" : 1231,
      "ownerId" : "531e7789e4b0853ddb861313"
      }

      and in the model I'm doing cast(_map[\'date\'] AS DATE) AS \"date\"

      Is this an issue with the date format? I'm tried casting as TIMESTAMP as well, and get a similar issue but it's casting as a Float rather than an Integer.

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/286
      Created by: ericblue
      Labels:
      Created at: Thu May 22 01:33:15 CEST 2014
      State: closed

        Activity

        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 01:35:12 CEST 2014, Author: julianhyde]

        Can you please post the error stack?

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 01:35:12 CEST 2014, Author: julianhyde ] Can you please post the error stack?
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 01:36:58 CEST 2014, Author: ericblue]

        java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.Integer
        at net.hydromatic.optiq.runtime.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:452)
        at net.hydromatic.optiq.runtime.AbstractCursor$DateFromIntAccessor.getDate(AbstractCursor.java:702)
        at net.hydromatic.optiq.runtime.AbstractCursor$DateFromIntAccessor.getObject(AbstractCursor.java:697)
        at net.hydromatic.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:351)
        at sqlline.Rows$Row.<init>(Rows.java:157)
        at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63)
        at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
        at sqlline.SqlLine.print(SqlLine.java:1653)
        at sqlline.Commands.execute(Commands.java:833)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 01:36:58 CEST 2014, Author: ericblue ] java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.Integer at net.hydromatic.optiq.runtime.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:452) at net.hydromatic.optiq.runtime.AbstractCursor$DateFromIntAccessor.getDate(AbstractCursor.java:702) at net.hydromatic.optiq.runtime.AbstractCursor$DateFromIntAccessor.getObject(AbstractCursor.java:697) at net.hydromatic.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:351) at sqlline.Rows$Row.<init>(Rows.java:157) at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63) at sqlline.TableOutputFormat.print(TableOutputFormat.java:33) at sqlline.SqlLine.print(SqlLine.java:1653) at sqlline.Commands.execute(Commands.java:833) at sqlline.Commands.sql(Commands.java:732) at sqlline.SqlLine.dispatch(SqlLine.java:808) at sqlline.SqlLine.begin(SqlLine.java:681) at sqlline.SqlLine.start(SqlLine.java:398) at sqlline.SqlLine.main(SqlLine.java:292)
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 01:54:28 CEST 2014, Author: julianhyde]

        Sounds like a bug. Dates are only represented as ints if they are in "internal format", whereas this date has come straight out of MongoDB. I might have fixed something like this recently – worth trying the latest.

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 01:54:28 CEST 2014, Author: julianhyde ] Sounds like a bug. Dates are only represented as ints if they are in "internal format", whereas this date has come straight out of MongoDB. I might have fixed something like this recently – worth trying the latest.
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 02:14:51 CEST 2014, Author: ericblue]

        I did a clone and mvn install from master. Is this the most recent or should I be using another branch/tag?

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 02:14:51 CEST 2014, Author: ericblue ] I did a clone and mvn install from master. Is this the most recent or should I be using another branch/tag?
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 02:17:13 CEST 2014, Author: julianhyde]

        You have the latest.

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 02:17:13 CEST 2014, Author: julianhyde ] You have the latest.
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 16:12:25 CEST 2014, Author: ericblue]

        Also, I'm not sure if this is a related issue, but even mapping "value" (listed above) as either a FLOAT or INTEGER doesn't work.

        select count from test where value > 800;
        Error: while executing SQL: select count from test where value > 800 (state=,code=0)

        Your test zips data and model seem to work just fine. And, all of your unit tests passed on the mvn install. Any thoughts you have on this would be appreciated. I could also send over the sample data and mapping if it helps with reproducing these issues.

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 16:12:25 CEST 2014, Author: ericblue ] Also, I'm not sure if this is a related issue, but even mapping "value" (listed above) as either a FLOAT or INTEGER doesn't work. select count from test where value > 800; Error: while executing SQL: select count from test where value > 800 (state=,code=0) Your test zips data and model seem to work just fine. And, all of your unit tests passed on the mvn install. Any thoughts you have on this would be appreciated. I could also send over the sample data and mapping if it helps with reproducing these issues.
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu May 22 21:43:38 CEST 2014, Author: julianhyde]

        I was able to reproduce the issue quite easily on the latest - a table with a single row, one column in which is a date.

        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 21:43:38 CEST 2014, Author: julianhyde ] I was able to reproduce the issue quite easily on the latest - a table with a single row, one column in which is a date.
        Hide
        github-import GitHub Import added a comment -

        [Date: Mon May 26 01:11:20 CEST 2014, Author: ericblue]

        Julian,

        I did a pull on your latest updates with the fix. With the changes, when I do a select * from the table I do see the date column and no exception is thrown.

        However, the date format is simply YYYY-M (ex. 2014-0) on all of the values. Any attempt to query 'select * from table where date > '2014-01-01' or even 'select * from table where date > '2014-0' results in an error.

        Error: while executing SQL: select * from table where date > '2014-01-01' (state=,code=0)

        Also, the other comment above where I noted similar behavior while mapping the integer or float is still true. Doing a select * the value shows, but any attempt to filter based on the value results in the (state=,code=0).

        Should the date issue be re-opened, and other issue created for the integer/float mapping?

        Show
        github-import GitHub Import added a comment - [Date: Mon May 26 01:11:20 CEST 2014, Author: ericblue ] Julian, I did a pull on your latest updates with the fix. With the changes, when I do a select * from the table I do see the date column and no exception is thrown. However, the date format is simply YYYY-M (ex. 2014-0) on all of the values. Any attempt to query 'select * from table where date > '2014-01-01' or even 'select * from table where date > '2014-0' results in an error. Error: while executing SQL: select * from table where date > '2014-01-01' (state=,code=0) Also, the other comment above where I noted similar behavior while mapping the integer or float is still true. Doing a select * the value shows, but any attempt to filter based on the value results in the (state=,code=0). Should the date issue be re-opened, and other issue created for the integer/float mapping?
        Hide
        github-import GitHub Import added a comment -

        [Date: Mon May 26 07:07:46 CEST 2014, Author: julianhyde]

        `'2014-01-01'` is a string. You need to use a date literal, `date '2014-01-01'`.

        Show
        github-import GitHub Import added a comment - [Date: Mon May 26 07:07:46 CEST 2014, Author: julianhyde ] `'2014-01-01'` is a string. You need to use a date literal, `date '2014-01-01'`.
        Hide
        github-import GitHub Import added a comment -

        [Date: Mon May 26 18:57:39 CEST 2014, Author: ericblue]

        I just tried with that syntax and am still getting (state=,code=0);

        Show
        github-import GitHub Import added a comment - [Date: Mon May 26 18:57:39 CEST 2014, Author: ericblue ] I just tried with that syntax and am still getting (state=,code=0);

          People

          • Assignee:
            Unassigned
            Reporter:
            github-import GitHub Import
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development