-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Incorrect/inconsistent unary test evaluation when nulls are involved. #864
Comments
@spearsandshields thank you for raising the issue and providing details. 👍 I see your point that the current behavior is not very intuitive. Let's have a look at the DMN specification for the expected behavior: (DMN 1.5, chapter 7.3.2, page 54) With these rules in mind, the following unary-tests expression should return: 1) Compare with implicit input value
Why?
Actual result:
Note: 2) Compare with null
Why?
Actual result:
3) Compare with ?
Why?
Actual result:
@spearsandshields do you agree with the expectations? @nikku please have a look at the expectations. |
@saig0 In short, I tend to agree with all of your understanding here, and your judgments in all these examples are helpful, and meet my updated expectation. Long story: While I agreed with your conclusion, I still wanted to double check this behavior through a different engine.
I made the above simple dmn file, and the results align with your scenario as well. A bit more background on why a fix of Scenario 3 will be beneficial. In real world, the context object can be very large, and not all properties guarantees a value. So if the expression involves (the use of ? is necessary for my use case, since this would allow users to put in expressions such as |
@spearsandshields thank you for confirming and providing more details. 👍
No, you don't need to use Try in FEEL-Scala Playground.
|
Related issue in I subscribe to your analysis. What would probably help us (and this is on my todo list) is to assert such cases clearly via the DMN TCK. To my knowledge both tools use the TCK for testing and behave differently; this indicates a lack of test coverage 🐳. |
@saig0 , thanks for sharing a workaround. Yes, the comma delimiter is the first route I went with, since it is simpler. I could try to diverge and provide different solution when negation if involved, and when it is not. However, that still does not cover the negation case, and it will introduce more complexity. In short, I chose to introduce ? as it provides consistency and simplicity and it covers the negation case. Unsure if I misunderstood anything, but hopefully this argument make sense. Below is a screenshot. My interpretation is that comma is valid token for positive unary tests only. (which is a bit sad) All three engines demonstrate the same behavior PS: there are many examples for the need or negation. For example range checking, |
Describe the bug
There is some inconsistent handling of null when evaluating unary tests.
I will try to demonstrate below using real examples and screenshots.
null > 20
2. when input value is null. I would expect the same (since the unary test is not a simple unary test and is not using the input value at all). However, we are getting true. null > 20 => true? This seemed hard to reason about.
2. evaluating
? > 20
, and when input value is null.However, when i run in expression mode, or using feelin engine, I would see this evaluate to null. If I run it against dsntk, I would get null as the return value as well.
To Reproduce
Steps to reproduce the behavior:
1.Type in the values as shown in the screenshot in corresponding playground sites. or go to link to spot the inconsistency
https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=PyA%2BIDIw&context=ewp9&input-value=bnVsbA%3D%3D
https://nikku.github.io/feel-playground/?e=%3F+%3E+20&c=%7B%0A++%22%3F%22%3A+null%0A%7D&t=expression&st=true
Expected behavior
This is business critical as it directly impact which rule is determined as a match or not a match when nulls are involved in the evaluation context. It seems like the general consensus is to return null, or consider a rule as not a match for unary tests such as
? > 20
, when ? is null.Currently, these null resulting input values are causing unexpected behavior in rule match determination. I think null will be a more reasonable/spec-compliant return value.
![image](https://private-user-images.githubusercontent.com/11656422/338305372-7b8e6ae7-5cd1-4a58-abbf-69cb0fc59a96.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTcxNTgsIm5iZiI6MTczOTE5Njg1OCwicGF0aCI6Ii8xMTY1NjQyMi8zMzgzMDUzNzItN2I4ZTZhZTctNWNkMS00YTU4LWFiYmYtNjljYjBmYzU5YTk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDE0MTQxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIzNjIwNDQ4NmNmZWJkNTIwMDcyZDQxN2RmYjI2OTYyMGIxY2RhMWQ5OWIxNGY1OWUwMmNmYTc4ODhjMTExYmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HjNIFQQ_bBk_pZ-6WBhtp8CrXbLNl-LTfJbkSdmybvU)
Environment
Related
SUPPORT-22286
The text was updated successfully, but these errors were encountered: