Skip to content

Commit bea403f

Browse files
committed
add type checking for uknown
1 parent 763fae1 commit bea403f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sqlglot/optimizer/annotate_types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,11 @@ def annotate_scope(self, scope: Scope) -> None:
386386
scope.expression.meta["query_type"] = struct_type
387387

388388
def _maybe_annotate(self, expression: E) -> E:
389-
if id(expression) in self._visited or (not self._overwrite_types and expression.type):
389+
if id(expression) in self._visited or (
390+
not self._overwrite_types
391+
and expression.type
392+
and not expression.is_type(exp.DataType.Type.UNKNOWN)
393+
):
390394
return expression # We've already inferred the expression's type
391395

392396
annotator = self.annotators.get(expression.__class__)

0 commit comments

Comments
 (0)