Skip to content

[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

Merged
merged 12 commits into from
Jul 17, 2025

Conversation

AthiraHari77
Copy link
Contributor

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

    • Push a new commit to the PR. An empty commit would be enough.
  • for a full downstream build

    • for github actions job: add the label run_fdb
  • for Jenkins PR check only

Copy link
Contributor

@gitgabrio gitgabrio left a 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!

@yesamer yesamer added the DMN label Jul 9, 2025
@yesamer yesamer requested a review from Copilot July 11, 2025 08:00
Copy link

@Copilot Copilot AI left a 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 in EvalHelper.getDefinedValue for ChronoPeriod, Duration, LocalTime, OffsetTime, LocalDate, and ZonedDateTime.
  • 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 and ZonedDateTime 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 example time("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) {

@yesamer yesamer requested a review from baldimir July 11, 2025 08:09
Copy link
Contributor

@yesamer yesamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @AthiraHari77

@baldimir baldimir merged commit d964d3d into apache:main Jul 17, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decision Engine: Support new property "value" for types date, date and time, years and months duration, days and time duration
4 participants