Skip to content

Commit

Permalink
fix: handle CRLF endings causing sqlglot failure (#26911)
Browse files Browse the repository at this point in the history
(cherry picked from commit f2bf9f7)
  • Loading branch information
mapledan authored and michael-s-molina committed Feb 1, 2024
1 parent af079fb commit efae3e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions superset/sql_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _extract_tables_from_sql(self) -> set[Table]:
Note: this uses sqlglot, since it's better at catching more edge cases.
"""
try:
statements = parse(self.sql, dialect=self._dialect)
statements = parse(self.stripped(), dialect=self._dialect)
except ParseError:
logger.warning("Unable to parse SQL (%s): %s", self._dialect, self.sql)
return set()
Expand Down Expand Up @@ -493,7 +493,7 @@ def is_unknown(self) -> bool:
return self._parsed[0].get_type() == "UNKNOWN"

def stripped(self) -> str:
return self.sql.strip(" \t\n;")
return self.sql.strip(" \t\r\n;")

def strip_comments(self) -> str:
return sqlparse.format(self.stripped(), strip_comments=True)
Expand Down

0 comments on commit efae3e7

Please sign in to comment.