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:
Родитель
fbf9894251
Коммит
e7215801b4
|
@ -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,
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче