diff --git a/sqlglot/typing/__init__.py b/sqlglot/typing/__init__.py index ca1a370dc4..0f95a2e939 100644 --- a/sqlglot/typing/__init__.py +++ b/sqlglot/typing/__init__.py @@ -22,7 +22,9 @@ }, **{ expr_type: {"annotator": lambda self, e: self._annotate_unary(e)} - for expr_type in subclasses(exp.__name__, (exp.Unary, exp.Alias)) + for expr_type in subclasses( + exp.__name__, (exp.Unary, exp.Alias, exp.IgnoreNulls, exp.RespectNulls) + ) }, **{ expr_type: {"returns": exp.DType.BIGINT} diff --git a/tests/fixtures/optimizer/annotate_functions.sql b/tests/fixtures/optimizer/annotate_functions.sql index 6140ac1a7a..8799b883fc 100644 --- a/tests/fixtures/optimizer/annotate_functions.sql +++ b/tests/fixtures/optimizer/annotate_functions.sql @@ -6375,4 +6375,15 @@ VARCHAR; # dialect: clickhouse MD5(tbl.str_col); -FIXEDSTRING(16); \ No newline at end of file +FIXEDSTRING(16); +-------------------------------------- +-- IGNORE NULLS / RESPECT NULLS +-------------------------------------- + +# dialect: spark, databricks, snowflake, bigquery, trino, redshift +FIRST_VALUE(tbl.str_col) IGNORE NULLS; +TEXT; + +# dialect: spark, databricks, snowflake, bigquery, trino, redshift +LAST_VALUE(tbl.str_col) RESPECT NULLS; +TEXT;