Skip to content

Commit 9a30200

Browse files
committed
fix tests
1 parent c469b3a commit 9a30200

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

sqlglot/optimizer/simplify.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -831,15 +831,15 @@ def remove_complements(self, expression, root=True):
831831
"""
832832
Removing complements.
833833
834-
A AND NOT A -> FALSE (only for non-NULL A)
835-
A OR NOT A -> TRUE (only for non-NULL A)
836-
"""
837-
if isinstance(expression, AND_OR) and (root or not expression.same_parent):
838-
ops = set(expression.flatten())
839-
for op in ops:
840-
if isinstance(op, exp.Not) and op.this in ops:
841-
if expression.meta.get("nonnull") is True:
842-
return exp.false() if isinstance(expression, exp.And) else exp.true()
834+
A AND NOT A -> FALSE (only for non-NULL A)
835+
A OR NOT A -> TRUE (only for non-NULL A)
836+
"""
837+
if isinstance(expression, self.AND_OR) and (root or not expression.same_parent):
838+
ops = set(expression.flatten())
839+
for op in ops:
840+
if isinstance(op, exp.Not) and op.this in ops:
841+
if expression.meta.get("nonnull") is True:
842+
return exp.false() if isinstance(expression, exp.And) else exp.true()
843843

844844
return expression
845845

tests/fixtures/optimizer/simplify.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ COALESCE(x, 1) = 1;
904904
x = 1 OR x IS NULL;
905905

906906
COALESCE(x, 1) IS NULL;
907-
NOT x IS NULL AND x IS NULL;
907+
FALSE;
908908

909909
COALESCE(ROW() OVER (), 1) = 1;
910910
ROW() OVER () = 1 OR ROW() OVER () IS NULL;

0 commit comments

Comments
 (0)