diff --git a/superset/sql_parse.py b/superset/sql_parse.py index 07704171dee3d..7b89ab8f0e2cb 100644 --- a/superset/sql_parse.py +++ b/superset/sql_parse.py @@ -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() @@ -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)