datafusion_common/null_equality.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
3// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
4
5/// Represents the behavior for null values when evaluating equality. Currently, its primary use
6/// case is to define the behavior of joins for null values.
7///
8/// # Examples
9///
10/// The following table shows the expected equality behavior for `NullEquality`.
11///
12/// | A | B | NullEqualsNothing | NullEqualsNull |
13/// |------|------|-------------------|----------------|
14/// | NULL | NULL | false | true |
15/// | NULL | 'b' | false | false |
16/// | 'a' | NULL | false | false |
17/// | 'a' | 'b' | false | false |
18///
19/// # Order
20///
21/// The order on this type represents the "restrictiveness" of the behavior. The more restrictive
22/// a behavior is, the fewer elements are considered to be equal to null.
23/// [NullEquality::NullEqualsNothing] represents the most restrictive behavior.
24///
25/// This mirrors the old order with `null_equals_null` booleans, as `false` indicated that
26/// `null != null`.
27#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Hash)]
28pub enum NullEquality {
29 /// Null is *not* equal to anything (`null != null`)
30 NullEqualsNothing,
31 /// Null is equal to null (`null == null`)
32 NullEqualsNull,
33}