Consider implementing sane comparisons for Intervals
Feature request
There's no requirement in Dataflow/Materialize for ordering to be deterministic, that limitation only exists with equality. So as far as Dataflow/Materialize is concerned, we can implement PartialOrd and Ord on Interval such that we consider 24 hours equal to 1 day (and 30 days equal to 1 month).
However I do think there is a limitation in Rust that prevents this. The PartialOrd docs contain the following (https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html):
The methods of this trait must be consistent with each other and with those of PartialEq in the following sense: a == b if and only if partial_cmp(a, b) == Some(Equal). a < b if and only if partial_cmp(a, b) == Some(Less) (ensured by the default implementation). a > b if and only if partial_cmp(a, b) == Some(Greater) (ensured by the default implementation). a <= b if and only if a < b || a == b (ensured by the default implementation). a >= b if and only if a > b || a == b (ensured by the default implementation). a != b if and only if !(a == b) (already part of PartialEq).
So I'm not sure that's it's possible to implement PartialOrd in a "sane" way where we consider 24 hours == 1 day without also implementing Eq and PartialEq to consider 24 hours == 1 day.
Though there is a potential workaround I was considering where we arbitrarily say that 1 day > 24 hours, and 1 day < 24 hours 1 microsecond. That may allow us to sanely order Interval's without breaking the requirement Rust imposes on PartialOrd and PartialEq.
Once #10566 is fixed then we can fully support 24 hours == 1 day.
I don't think we can just special case some scenarios and we will have to handle it gracefully. For example consider the following scenarios:
- 1 day > 24 hrs
- 2 days > 48 hrs
- x months 1 day > x months 24 hrs
- x months 1 day ?? y months 24 hours
cc @chaas @ggnall we should re-triage this in light of #14163
@chaas This was still on the old project and I moved it to surfaces. Can we remove the C-triage label after issues are reflected on the board?