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
1 change: 1 addition & 0 deletions sqlglot/dialects/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ class BigQuery(Dialect):
exp.RegexpExtractAll: lambda self, e: self._annotate_by_args(e, "this", array=True),
exp.Replace: lambda self, e: self._annotate_by_args(e, "this"),
exp.Reverse: lambda self, e: self._annotate_by_args(e, "this"),
exp.Soundex: lambda self, e: self._annotate_with_type(e, exp.DataType.Type.VARCHAR),
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"),
Expand Down
4 changes: 4 additions & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6845,6 +6845,10 @@ class SortArray(Func):
arg_types = {"this": True, "asc": False}


class Soundex(Func):
pass


class Split(Func):
arg_types = {"this": True, "expression": True, "limit": False}

Expand Down
38 changes: 38 additions & 0 deletions tests/dialects/test_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3930,3 +3930,41 @@ def test_translate(self):
"oracle": "TRANSLATE(x, y, z)",
},
)

def test_soundex(self):
self.validate_all(
"SOUNDEX(x)",
read={
"": "SOUNDEX(x)",
"bigquery": "SOUNDEX(x)",
"hive": "SOUNDEX(x)",
"spark2": "SOUNDEX(x)",
"spark": "SOUNDEX(x)",
"databricks": "SOUNDEX(x)",
"mysql": "SOUNDEX(x)",
"postgres": "SOUNDEX(x)",
"tsql": "SOUNDEX(x)",
"snowflake": "SOUNDEX(x)",
"dremio": "SOUNDEX(x)",
"trino": "SOUNDEX(x)",
"clickhouse": "SOUNDEX(x)",
"redshift": "SOUNDEX(x)",
"oracle": "SOUNDEX(x)",
},
write={
"bigquery": "SOUNDEX(x)",
"hive": "SOUNDEX(x)",
"spark2": "SOUNDEX(x)",
"spark": "SOUNDEX(x)",
"databricks": "SOUNDEX(x)",
"mysql": "SOUNDEX(x)",
"postgres": "SOUNDEX(x)",
"tsql": "SOUNDEX(x)",
"snowflake": "SOUNDEX(x)",
"dremio": "SOUNDEX(x)",
"trino": "SOUNDEX(x)",
"clickhouse": "SOUNDEX(x)",
"redshift": "SOUNDEX(x)",
"oracle": "SOUNDEX(x)",
},
)
4 changes: 4 additions & 0 deletions tests/fixtures/optimizer/annotate_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,10 @@ STRING;
TRANSLATE(b'AaBbCc', b'abc', b'123');
BINARY;

# dialect: bigquery
SOUNDEX('foo');
STRING;

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