diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-03 09:12:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-03 09:12:24 +0000 |
commit | 98d5537435b2951b36c45f1fda667fa27c165794 (patch) | |
tree | d26b4dfa6cf91847100fe10a94a04dcc2ad36a86 /sqlglot/optimizer/simplify.py | |
parent | Adding upstream version 11.5.2. (diff) | |
download | sqlglot-091f07175e8b976fcf301fe4832c1b7e0bc4eef0.tar.xz sqlglot-091f07175e8b976fcf301fe4832c1b7e0bc4eef0.zip |
Adding upstream version 11.7.1.upstream/11.7.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/optimizer/simplify.py')
-rw-r--r-- | sqlglot/optimizer/simplify.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/sqlglot/optimizer/simplify.py b/sqlglot/optimizer/simplify.py index 28ae86d..4e6c910 100644 --- a/sqlglot/optimizer/simplify.py +++ b/sqlglot/optimizer/simplify.py @@ -201,23 +201,24 @@ def _simplify_comparison(expression, left, right, or_=False): return left if (av < bv if or_ else av >= bv) else right # we can't ever shortcut to true because the column could be null - if isinstance(a, exp.LT) and isinstance(b, GT_GTE): - if not or_ and av <= bv: - return exp.false() - elif isinstance(a, exp.GT) and isinstance(b, LT_LTE): - if not or_ and av >= bv: - return exp.false() - elif isinstance(a, exp.EQ): - if isinstance(b, exp.LT): - return exp.false() if av >= bv else a - if isinstance(b, exp.LTE): - return exp.false() if av > bv else a - if isinstance(b, exp.GT): - return exp.false() if av <= bv else a - if isinstance(b, exp.GTE): - return exp.false() if av < bv else a - if isinstance(b, exp.NEQ): - return exp.false() if av == bv else a + if not or_: + if isinstance(a, exp.LT) and isinstance(b, GT_GTE): + if av <= bv: + return exp.false() + elif isinstance(a, exp.GT) and isinstance(b, LT_LTE): + if av >= bv: + return exp.false() + elif isinstance(a, exp.EQ): + if isinstance(b, exp.LT): + return exp.false() if av >= bv else a + if isinstance(b, exp.LTE): + return exp.false() if av > bv else a + if isinstance(b, exp.GT): + return exp.false() if av <= bv else a + if isinstance(b, exp.GTE): + return exp.false() if av < bv else a + if isinstance(b, exp.NEQ): + return exp.false() if av == bv else a return None |