Skip to content

Commit 2b5f95a

Browse files
committed
fix annotation call
1 parent 43d0258 commit 2b5f95a

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

sqlglot/optimizer/annotate_types.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,12 @@ def _annotate_unary(self, expression: E) -> E:
477477
else:
478478
self._set_type(expression, expression.this.type)
479479

480-
if this_type := expression.this.type:
481-
nonnull = this_type.args.get("nonnull")
482-
if nonnull and (expr_type := expression.type):
483-
expr_type.set("nonnull", nonnull)
480+
if (
481+
(this_type := expression.this.type)
482+
and this_type.args.get("nonnull")
483+
and (expr_type := expression.type)
484+
):
485+
expr_type.set("nonnull", True)
484486

485487
return expression
486488

sqlglot/typing/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
},
2222
**{
2323
expr_type: {"annotator": lambda self, e: self._annotate_unary(e)}
24-
for expr_type in subclasses(exp.__name__, (exp.Unary, exp.Alias), {exp.Not})
25-
},
26-
**{
27-
expr_type: {"returns": exp.DataType.Type.BOOLEAN}
28-
for expr_type in subclasses(exp.__name__, (exp.Connector, exp.Predicate))
24+
for expr_type in subclasses(exp.__name__, (exp.Unary, exp.Alias))
2925
},
3026
**{
3127
expr_type: {"returns": exp.DataType.Type.BIGINT}
@@ -58,7 +54,6 @@
5854
exp.In,
5955
exp.LogicalAnd,
6056
exp.LogicalOr,
61-
exp.Not,
6257
exp.RegexpLike,
6358
exp.StartsWith,
6459
}

0 commit comments

Comments
 (0)