Skip to content

between has odd behavior for null timespan #161

Description

@electrum

Consider the following:

print
    date(2001) between (date(2000) .. date(null)),      // null: possibly true
    date(2001) between (date(null) .. date(2002)),      // null: possibly true
    date(2001) between (date(2002) .. date(null)),      // false: impossible
    date(2001) between (date(null) .. date(2000)),      // false: impossible
    date(2001) between (date(2000) .. timespan(null)),  // false: possibly true!
    date(2001) between (date(2002) .. timespan(null))   // null: possibly true for negative timespan

In the case of a null timespan, returning false seems incorrect, since the expression could be true if the unknown timespan has a suitable positive value. In the case where the left value is greater than the expression value, the result could still be true for a suitable negative timespan, so returning null seems correct.

Kusto supports between with negative timespans, but not reversed left/right bounds:

print
    date(2001-05-05) between (date(2001-05-10) .. -10d),            // true
    date(2001-05-05) between (date(2001-05-10) .. date(2001-05-01)) // false

Is the above expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions