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

beto pushed a commit to branch firebolt-old-quote
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 77cf69e9ac00b936337e4754014ddf46ca0e80e8
Author: Beto Dealmeida <[email protected]>
AuthorDate: Fri Feb 21 11:07:06 2025 -0600

    fix(firebolt): allow backslach escape for single quotes
---
 superset/sql/dialects/firebolt.py   |  5 ++++-
 tests/unit_tests/sql/parse_tests.py | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/superset/sql/dialects/firebolt.py 
b/superset/sql/dialects/firebolt.py
index a4767596f4..cfdfc2dfe6 100644
--- a/superset/sql/dialects/firebolt.py
+++ b/superset/sql/dialects/firebolt.py
@@ -17,7 +17,7 @@
 
 from __future__ import annotations
 
-from sqlglot import exp, generator, parser
+from sqlglot import exp, generator, parser, tokens
 from sqlglot.dialects.dialect import Dialect
 from sqlglot.helper import csv
 from sqlglot.tokens import TokenType
@@ -84,6 +84,9 @@ class FireboltOld(Firebolt):
     function.
     """
 
+    class Tokenizer(tokens.Tokenizer):
+        STRING_ESCAPES = ["'", "\\"]
+
     class Parser(Firebolt.Parser):
         TABLE_ALIAS_TOKENS = Firebolt.Parser.TABLE_ALIAS_TOKENS - 
{TokenType.UNNEST}
 
diff --git a/tests/unit_tests/sql/parse_tests.py 
b/tests/unit_tests/sql/parse_tests.py
index 2df24a1b3a..419886aaff 100644
--- a/tests/unit_tests/sql/parse_tests.py
+++ b/tests/unit_tests/sql/parse_tests.py
@@ -1164,3 +1164,21 @@ def test_firebolt_old() -> None:
   *
 FROM t1 UNNEST(col1 AS foo)"""
     )
+
+
+def test_firebolt_old_escape_string() -> None:
+    """
+    Test the dialect for the old Firebolt syntax.
+    """
+    from superset.sql.dialects import FireboltOld
+    from superset.sql.parse import SQLGLOT_DIALECTS
+
+    SQLGLOT_DIALECTS["firebolt"] = FireboltOld
+
+    sql = r"SELECT 'foo''bar', 'foo\'bar'"
+    assert (
+        SQLStatement(sql, "firebolt").format()
+        == """SELECT
+  'foo''bar',
+  'foo''bar'"""
+    )

Reply via email to