mz_transform/notice/
equals_null.rs1use std::collections::BTreeSet;
13use std::fmt;
14
15use mz_repr::GlobalId;
16use mz_repr::explain::ExprHumanizer;
17
18use crate::notice::{ActionKind, OptimizerNoticeApi};
19
20#[derive(Clone, Debug, Eq, PartialEq, Hash)]
25pub struct EqualsNull;
26
27impl OptimizerNoticeApi for EqualsNull {
28 fn dependencies(&self) -> BTreeSet<GlobalId> {
29 BTreeSet::new()
30 }
31
32 fn fmt_message(
33 &self,
34 f: &mut fmt::Formatter<'_>,
35 _humanizer: &dyn ExprHumanizer,
36 _redacted: bool,
37 ) -> fmt::Result {
38 write!(
39 f,
40 "Comparison with NULL using `=` or `<>` always returns NULL."
41 )
42 }
43
44 fn fmt_hint(
45 &self,
46 f: &mut fmt::Formatter<'_>,
47 _humanizer: &dyn ExprHumanizer,
48 _redacted: bool,
49 ) -> fmt::Result {
50 write!(f, "Use `IS NULL` or `IS NOT NULL` instead.")
51 }
52
53 fn fmt_action(
54 &self,
55 _f: &mut fmt::Formatter<'_>,
56 _humanizer: &dyn ExprHumanizer,
57 _redacted: bool,
58 ) -> fmt::Result {
59 Ok(())
60 }
61
62 fn action_kind(&self, _humanizer: &dyn ExprHumanizer) -> ActionKind {
63 ActionKind::None
64 }
65}