Remove sqlglot workarounds which are no longer necessary (#5384)

* Remove workaround for sqlglot not supporting byte strings.

sqlglot support for byte strings was fixed in v12.2.0.

This workaround also caused parsing failures if the SQL contained a raw string that ended with `\b`, because it removed the `b` so the raw string ended with a backlash, which isn't valid.

* Remove workaround for sqlglot not supporting `OPTIONS` on UDFs.

sqlglot support for `OPTIONS` on UDFs was fixed in v18.7.0.

* Update workaround for sqlglot not supporting UDFs with keyword names.

sqlglot support for UDFs with the same name as built-in functions was fixed in v12.0.0.
This commit is contained in:
Sean Rose 2024-04-17 11:19:34 -07:00 коммит произвёл GitHub
Родитель fbf9894251
Коммит e7215801b4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 3 добавлений и 17 удалений

Просмотреть файл

@ -39,24 +39,10 @@ def extract_table_references(sql: str) -> List[str]:
if re.search(r"^\s*DECLARE\b", sql, flags=re.MULTILINE):
return []
# sqlglot parses UDFs with keyword names incorrectly:
# https://github.com/tobymao/sqlglot/issues/1535
# https://github.com/tobymao/sqlglot/issues/3332
sql = re.sub(
r"\.(range|true|false|null)\(",
r".\1_(",
sql,
flags=re.IGNORECASE,
)
# sqlglot doesn't suppport OPTIONS on UDFs
sql = re.sub(
r"""OPTIONS\s*\(("([^"]|\\")*"|'([^']|\\')*'|[^)])*\)""",
"",
sql,
flags=re.MULTILINE | re.IGNORECASE,
)
# sqlglot doesn't fully support byte strings
sql = re.sub(
r"""b(["'])""",
r"\1",
r"\.(true|false|null)\(",
r".`\1`(",
sql,
flags=re.IGNORECASE,
)