Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sqlglot/dialects/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ class BigQuery(Dialect):
},
exp.ArrayConcat: lambda self, e: self._annotate_by_args(e, "this", "expressions"),
exp.Concat: _annotate_concat,
exp.SHA: lambda self, e: self._annotate_with_type(e, exp.DataType.Type.BINARY),
exp.SHA2: lambda self, e: self._annotate_with_type(e, exp.DataType.Type.BINARY),
exp.Sign: lambda self, e: self._annotate_by_args(e, "this"),
exp.Split: lambda self, e: self._annotate_by_args(e, "this", array=True),
}
Expand Down
2 changes: 0 additions & 2 deletions sqlglot/dialects/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,6 @@ class Dialect(metaclass=_Dialect):
},
exp.DataType.Type.BINARY: {
exp.FromBase64,
exp.SHA,
exp.SHA2,
},
exp.DataType.Type.BOOLEAN: {
exp.Between,
Expand Down
18 changes: 12 additions & 6 deletions tests/fixtures/optimizer/annotate_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ BIGINT;
STARTS_WITH(tbl.str_col, prefix);
BOOLEAN;

SHA(str_col);
BINARY;

SHA2(str_col);
BINARY;

--------------------------------------
-- Spark2 / Spark3 / Databricks
--------------------------------------
Expand Down Expand Up @@ -558,6 +552,18 @@ BOOLEAN;
MAKE_INTERVAL(1, 6, 15);
INTERVAL;

# dialect: bigquery
SHA1(str_col);
BINARY;

# dialect: bigquery
SHA256(str_col);
BINARY;

# dialect: bigquery
SHA512(str_col);
BINARY;

--------------------------------------
-- Snowflake
--------------------------------------
Expand Down