MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / compare_columns

Function compare_columns

src/expr/src/relation.rs:3835–3874  ·  view source on GitHub ↗

Compare `left` and `right` using `order`. If that doesn't produce a strict ordering, call `tiebreaker`.

(
    order: &[ColumnOrder],
    left: &[Datum],
    right: &[Datum],
    tiebreaker: F,
)

Source from the content-addressed store, hash-verified

3833/// Compare `left` and `right` using `order`. If that doesn't produce a strict
3834/// ordering, call `tiebreaker`.
3835pub fn compare_columns<F>(
3836 order: &[ColumnOrder],
3837 left: &[Datum],
3838 right: &[Datum],
3839 tiebreaker: F,
3840) -> Ordering
3841where
3842 F: Fn() -> Ordering,
3843{
3844 for order in order {
3845 let cmp = match (&left[order.column], &right[order.column]) {
3846 (Datum::Null, Datum::Null) => Ordering::Equal,
3847 (Datum::Null, _) => {
3848 if order.nulls_last {
3849 Ordering::Greater
3850 } else {
3851 Ordering::Less
3852 }
3853 }
3854 (_, Datum::Null) => {
3855 if order.nulls_last {
3856 Ordering::Less
3857 } else {
3858 Ordering::Greater
3859 }
3860 }
3861 (lval, rval) => {
3862 if order.desc {
3863 rval.cmp(lval)
3864 } else {
3865 lval.cmp(rval)
3866 }
3867 }
3868 };
3869 if cmp != Ordering::Equal {
3870 return cmp;
3871 }
3872 }
3873 tiebreaker()
3874}
3875
3876/// Describe a window frame, e.g. `RANGE UNBOUNDED PRECEDING` or
3877/// `ROWS BETWEEN 5 PRECEDING AND CURRENT ROW`.

Callers 6

compare_rowsMethod · 0.70
process_responseMethod · 0.50
send_batchMethod · 0.50
build_topk_negated_stageFunction · 0.50
cmpMethod · 0.50

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected