-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[Incubator kie issues#2023] Decision Engine: Support new property "value" for types date
, date and time
, years and months duration
, days and time duration
#6394
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
Conversation
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AthiraHari77
Could you please write some tests to verify the following sentence from specs:
We write valuedt(d) to represent the number of seconds between d and the epoch. The valuedt
function is one- to-one and so it has an inverse function valuedt -1. E.g., valuedt-1(valuedt(d)) = d. valuedt -1 returns null
rather than a date with a year outside the legal range
?
Thanks!
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
Show resolved
Hide resolved
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the new value
property on FEEL date/time and duration types by calculating and returning the appropriate numeric representation (seconds since epoch or seconds since midnight, or total months).
- Implemented
value
cases inEvalHelper.getDefinedValue
forChronoPeriod
,Duration
,LocalTime
,OffsetTime
,LocalDate
, andZonedDateTime
. - Expanded existing tests and data-driven FEEL tests to cover
.value
on date, date and time, time, and duration types. - Added new JUnit tests for
LocalTime
andZonedDateTime
round-trip via.value
.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java | Added value switch blocks to compute numeric values for periods, durations, and temporal objects |
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/EvalHelperTest.java | New tests testValueForLocalTime and testValueForZonedDateTime validating value round-trip |
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java | Extended test data table to include .value on various FEEL expressions |
Comments suppressed due to low confidence (2)
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/util/EvalHelperTest.java:82
- Add a unit test for
OffsetTime
.value
(for exampletime("13:20:00+02:00").value
) to verify that offset times produce the expected seconds-since-midnight result.
}
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java:188
- Using pattern matching for
instanceof
(e.g.,instanceof LocalDate date
) requires Java 16 or higher. If this project targets Java 11, switch to the traditional pattern (if (current instanceof LocalDate) { LocalDate date = (LocalDate) current; ... }
) for broader compatibility.
} else if (current instanceof LocalDate date) {
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @AthiraHari77
This PR aims to introduce a new property "value" for types
time
,date
,date and time
,years and months duration
,days and time duration
.Closes : apache/incubator-kie-issues#2023
for pull request and downstream checks
for a full downstream build
run_fdb
for Jenkins PR check only
Build Now
button.