Skip to content

#140 add support for intervals on ProperlyIncludesIn - #141

Open
vfrank66 wants to merge 2 commits into
google:mainfrom
vfrank66:issue_140-properlyincludesin-add-intervals
Open

vfrank66 wants to merge 2 commits into
google:mainfrom
vfrank66:issue_140-properlyincludesin-add-intervals

Conversation

@vfrank66

Copy link
Copy Markdown
Contributor

No description provided.

@evan-gordon evan-gordon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall looks good! Mostly just a few cosmetic comments.

Comment thread interpreter/operator_interval.go Outdated
var includedIn bool

// Handle null bounds
if result.IsNull(leftStart) || result.IsNull(leftEnd) || result.IsNull(rightStart) || result.IsNull(rightEnd) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this not work in the case of Intverval(null, 1] and Interval[5, null) where we can definitively say that one is not included in the other? Consider adding a test for this sort of a case.

Comment thread interpreter/operator_interval.go Outdated

includedIn = (startComp == leftBeforeRight || startComp == leftEqualRight) &&
(endComp == leftBeforeRight || endComp == leftEqualRight)
} else {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we could use a helper method similar to

func arithmetic[t float64 | int64 | int32](m model.IBinaryExpression, l, r t) (result.Value, error) {
here.

Comment thread interpreter/operator_interval.go Outdated
}

// Check units match
if leftStartQty.Unit != rightStartQty.Unit || leftEndQty.Unit != rightEndQty.Unit {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

mind using the ucum lib here? that should rather easily allow for handling this case.

…bounds, ucum

ProperlyIncludedIn for intervals now compares the closed start and end of
both intervals through one helper, compareIntervalPoints, built on a
generic compareValues. Quantity points convert units with the ucum
library instead of rejecting differing units.

An unknown start is bounded by the interval's end (and an unknown end by
its start), so Interval(null, 1] properly included in Interval[5, null)
returns false instead of null.

Comparing the normalised bounds also fixes two cases the old equality
check got wrong: Interval[1, 5] and Interval[1, 6) are the same interval,
and Quantity and Time bounds were compared as zero floats. The
QuantityIntervalProperlyIncludedInTrue and TimeProperlyIncludedInTrue
spec tests now pass. IntegerIntervalProperlyIncludedInNullBoundaries
stays excluded under the existing ambiguous-match bug, because
Interval[null, null] does not resolve in the parser.

The Interval<String> overload is removed: the Interval selector has no
String overload, so it could not be reached.
@vfrank66
vfrank66 force-pushed the issue_140-properlyincludesin-add-intervals branch from cb6650e to 988b0ba Compare October 11, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants