You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2024/02/01 02:07:49 UTC

(superset) branch master updated: fix: handle CRLF endings causing sqlglot failure (#26911)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new f2bf9f72e4 fix: handle CRLF endings causing sqlglot failure (#26911)
f2bf9f72e4 is described below

commit f2bf9f72e4f17604f5db80f25815525236a7269a
Author: mapledan <ma...@gmail.com>
AuthorDate: Thu Feb 1 10:07:43 2024 +0800

    fix: handle CRLF endings causing sqlglot failure (#26911)
---
 superset/sql_parse.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index 07704171de..7b89ab8f0e 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -286,7 +286,7 @@ class ParsedQuery:
         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 @@ class ParsedQuery:
         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)