Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5981

DMN FEEL: arithmetic negation of function leads to null result

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Done
    • 7.47.0.Final
    • None
    • dmn engine
    • None
    • 2021 Week 04-06 (from Jan 25), 2021 Week 07-09 (from Feb 15)
    • 3
    • Hide

      This occurs on 7.47.0 as well as on current master. I tested this on master and based my examples on existing tests.

      Add (one of) the following examples to org.kie.dmn.feel.runtime.FEELFunctionsTest

      The test breaks on the cases without the 0-prefix.

      { "0-max( 1, 2, 3 )", BigDecimal.valueOf( -3 ) , null},
      { "-max( 1, 2, 3 )", BigDecimal.valueOf( -3 ) , null},
      { "0-sum( 1, 2, 3 )", BigDecimal.valueOf( -6 ) , null},
      { "-sum( 1, 2, 3 )", BigDecimal.valueOf( -6 ) , null},
      { "0-abs( 10 )", new BigDecimal("-10") , null},
      { "-abs( 10 )", new BigDecimal("-10") , null}, 
      Show
      This occurs on 7.47.0 as well as on current master. I tested this on master and based my examples on existing tests. Add (one of) the following examples to org.kie.dmn.feel.runtime.FEELFunctionsTest The test breaks on the cases without the 0-prefix. { "0-max( 1, 2, 3 )" , BigDecimal.valueOf( -3 ) , null }, { "-max( 1, 2, 3 )" , BigDecimal.valueOf( -3 ) , null }, { "0-sum( 1, 2, 3 )" , BigDecimal.valueOf( -6 ) , null }, { "-sum( 1, 2, 3 )" , BigDecimal.valueOf( -6 ) , null }, { "0-abs( 10 )" , new BigDecimal( "-10" ) , null }, { "-abs( 10 )" , new BigDecimal( "-10" ) , null },
    • NEW
    • NEW
    • ---
    • ---

    Description

      I noticed that a negated expression like -sum( 1, 2, 3 ) leads to a null result on evaluation. According to section 10.3.1.2 (page 111-113) of the DMN 1.2 specification document on item 26 "arithmetic negation" it should be possible to prefix a dash to a FEEL function. However, when evaluated, this makes the expression return null. The non-prefixed version as well as 0-expression works as expected.

      This is quite a low priority since there is an easy workaround (prefix 0). I observed this behaviour when running an extensive set of tests to validate conversion from a custom expression language in a client's product to DMN FEEL. I have adjusted the conversion using the workaround.

      Attachments

        Activity

          People

            mmortari@redhat.com Matteo Mortari
            oneton82 Anton Tieleman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: