Skip to content

Inclusive or exclusive range filters in API #9237

@mik-laj

Description

@mik-laj

Helllo,

We have the following ranger filter parameters:

  • FilterDurationGTE
  • FilterDurationLTE
  • FilterEndDateGTE
  • FilterEndDateLTE
  • FilterExecutionDateGTE
  • FilterExecutionDateLTE
  • FilterStartDateGTE
  • FilterStartDateLTE

Only closed ranged(in interval notation: [start_xxx, end_xxx]) can be fetched using them.

I think, filters representing ranges should use inclusive start values and exclusive end values (half-closed intervals); in interval notation: [start_xxx, end_xxx).

Exclusive end values are preferable for the following reasons:

  • It conforms to user expectations, particularly for continuous values such as timestamps, and avoids the need to express imprecise “limit values” (e.g. 2012-04-20T23:59:59).
  • It is consistent with most common programming languages, including C++, Java, Python, and Go.
  • It is easier to reason about abutting ranges: [0, x), [x, y), [y, z), where values are chainable from one range to the next.

More information: https://google.aip.dev/145

Alternatively, we can also add LT and GT filters, but this could only complicate situations without much benefit. We would have 4 different parameters for one field. Changing parameter names and changing behavior seems better to me.

Best regards,
Kamil Breguła

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions