Closed etirelli closed 6 years ago
The spec additionally says in table 54 on page 127 (row 3, column 4): "e1 is a list and type(FEEL(e2, s')) is boolean"
Conclusion: If e2 is not a boolean type (true or false) the expression is not applicable.
I think the complete result of the filter expression should be null.
@DanielThanner the main reason for my question is because of the "if" statement that says (page 120):
A conditional if a then b else c is equal to b if a is true, and equal to c otherwise.
And Gary confirmed that:
(if "foo" then 1 else 2) = 2
Page 113, on filters, says:
The filter expression is evaluated for each item in list, and a list containing only items where the filter expression is true is returned.
To be honest, my current implementation returns null, as you mentioned. But the above wording makes me think we might be wrong.
May be we should create a OMG ticket to clarify that issue for DMN 1.2.
I sent the question to Gary just in case. Once we hear from him we can open a ticket if necessary.
I think its worth an issue for the RTF. Table 59 (after ballot 13): Semantics of lists is unclear. The table should be captioned "Semantics of filters". It is unclear how to interpret Applicability. Must the expression be true for every list item? How is applicability related to the domain of the inputs to the filter? If an input is out of its specified domain, the the result must be null. But its not clear here...
FEEL has a 3-value logic. Hence returning only those elements for which the filter returns true
makes sense as true != null
.
I believe SQL takes the same approach. Same thing happens in Java if the filter returns null
and is compared against Boolean.TRUE
.
RTF discussed. Last comment above is correct. Closing.
The spec says, on page 113:
And:
Based on the above, what is the result when a filter evaluates to a non-boolean value and/or to an error?
E.g.:
Our understanding is that this should:
{ a : false, b : 2 }
,a
is afalse
boolean-literal, hence not selected,{ a : null, b : 3 }
,a
is thenull
literal, hence not selected{ b : 4 }
, there is noa
, the filter would be an error, hence return null, hence not selected{ a : true, b : 5 }
,a
is thetrue
boolean-literal, so it will be selectedThe result of the expression then would be: