datafusion_common/
null_equality.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18/// Represents the behavior for null values when evaluating equality. Currently, its primary use
19/// case is to define the behavior of joins for null values.
20///
21/// # Examples
22///
23/// The following table shows the expected equality behavior for `NullEquality`.
24///
25/// | A    | B    | NullEqualsNothing | NullEqualsNull |
26/// |------|------|-------------------|----------------|
27/// | NULL | NULL | false             | true           |
28/// | NULL | 'b'  | false             | false          |
29/// | 'a'  | NULL | false             | false          |
30/// | 'a'  | 'b'  | false             | false          |
31///
32/// # Order
33///
34/// The order on this type represents the "restrictiveness" of the behavior. The more restrictive
35/// a behavior is, the fewer elements are considered to be equal to null.
36/// [NullEquality::NullEqualsNothing] represents the most restrictive behavior.
37///
38/// This mirrors the old order with `null_equals_null` booleans, as `false` indicated that
39/// `null != null`.
40#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Hash)]
41pub enum NullEquality {
42    /// Null is *not* equal to anything (`null != null`)
43    NullEqualsNothing,
44    /// Null is equal to null (`null == null`)
45    NullEqualsNull,
46}