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

ArithmeticException when querying against decimal field.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • avatica
    • None

    Description

      Running against Phoenix:

      DROP TABLE IF EXISTS foo;
      CREATE TABLE IF NOT EXISTS foo (ID INTEGER PRIMARY KEY,decimal_id DECIMAL);
      
      UPSERT INTO foo VALUES (0,13.7);
      UPSERT INTO foo VALUES (1,13.7);
      UPSERT INTO foo VALUES (2,13.7);
      
      SELECT * FROM foo;
      

      Nets an exception on the client side:

      java.lang.ArithmeticException: Rounding necessary
      	at java.math.BigDecimal.divideAndRound(BigDecimal.java:1452)
      	at java.math.BigDecimal.setScale(BigDecimal.java:2402)
      	at org.apache.calcite.avatica.util.AbstractCursor$NumberAccessor.getBigDecimal(AbstractCursor.java:704)
      	at org.apache.calcite.avatica.util.AbstractCursor$NumberAccessor.getBigDecimal(AbstractCursor.java:708)
      	at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:327)
      	at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:381)
      	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)
      

      The above works without Avatica in the picture, so I'm assuming that something isn't working as it should in the Accessors.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            elserj Josh Elser
            elserj Josh Elser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment