Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-17438

Unable to sum decimal values which have non-default precision

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 2.14
    • None
    • sql
    • None
    • Docs Required, Release Notes Required

    Description

      Found the bug when creating unit tests. 

      Steps to reproduce:

      cache.query(new SqlFieldsQuery(
          """
            | CREATE TABLE numbers (
            |    id LONG,
            |    val DOUBLE,
            |    int_val LONG,
            |    decimal_val DECIMAL(5, 5),
            |    PRIMARY KEY (id)) WITH "backups=1"
          """.stripMargin)).getAll
      
       cache.query(qry.setArgs(18L.asInstanceOf[JLong], new java.math.BigDecimal(2.5))).getAll
      cache.query(qry.setArgs(19L.asInstanceOf[JLong], new java.math.BigDecimal(3.5))).getAll
      cache.query(qry.setArgs(20L.asInstanceOf[JLong], new java.math.BigDecimal(4.5))).getAll
      cache.query(qry.setArgs(21L.asInstanceOf[JLong], new java.math.BigDecimal(4.5))).getAll
      
      cache.query(new SqlFieldsQuery("SELECT SUM(decimal_val) FROM numbers WHERE id IN (18, 19, 20)")).getAll

      Result:

      class org.apache.ignite.internal.processors.query.IgniteSQLException: Numeric value out of range: "5"; SQL statement:
      SELECT
      CAST(CAST(SUM(__C0_0) AS DECIMAL(5, 5)) AS DECIMAL(5, 5)) __C0_0
      FROM PUBLIC.__T0 [22003-197] 

      Attachments

        Activity

          People

            Unassigned Unassigned
            ivan.gagarkin Ivan Gagarkin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: