Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle CRLF endings causing sqlglot failure #26911

Merged
merged 4 commits into from
Feb 1, 2024
Merged
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
4 changes: 2 additions & 2 deletions superset/sql_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,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 @@ -494,7 +494,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
Loading