Skip to content
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

Fixes #1464: Create apoc.temporal.overlap(start1, end1, start2, end2, acceptAdjacentSpans:true) function #3994

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

vga91
Copy link
Collaborator

@vga91 vga91 commented Mar 6, 2024

Fixes #1464

Created apoc.temporal.overlap function.

  • TO EVALUATE: It also refers to temporal spans, but perhaps it is worth considering all possible data types, for example to compare two ranges of longs (e.g. with 1 as start1, 4 as end1, 3 as start2, 4 as end2 return (start1 < end2) AND (start2 < end1) AS value).
    In that case, we could rename the procedure as apoc.util.overlap.

  • TO EVALUATE: Consistently with Cypher, if the data types are not comparable (see testOverlapWithWrongTypes), the procedure returns null.
    Alternatively, we could return for example a RuntimeException("type not comparable..."),
    or perhaps we can add another config failSilently: <boolean> that returns null if the config true.

  • The issue suggests using max(start1, start2) <= min(end1, end2), but for simplicity, I think it is better to use the other formula suggested in stackoverflow, that is (Start1 <= End2) and (Start2 <= End1).

  • The procedure leverages tx.execute(<query>) instead of using the Java API, e.g. the AnyValues.COMPARATOR, since this way we are sure that the behavior is consistent with Cypher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant