betodealmeida commented on issue #26162:
URL: https://github.com/apache/superset/issues/26162#issuecomment-2956211456

   > P.S: While investigating, I also took a look at sqlglot, but sqlglot does 
not have a _split_ method like sqlparse does. I started working on adding one, 
but if the issue get fixed in sqlparse it won't be necessary... unless if you 
want to rely solely on sqlglot and stop using sqlparse ?
   > 
   > The advantage of switching to sqlglot would be if some SQL dialects ever 
require an even more exotic way of splitting, it could be added there.
   
   We've moved on to `sqlglot`, and `sqlparse` is no longer used. See 
https://github.com/apache/superset/issues/26786.
   
   I tested this with the latest `sqlglot` and it stlil doesn't work:
   
   ```python
   >>> import sqlglot
   >>> sqlglot.__version__
   '26.25.3'
   >>> sqlglot.parse("""
   ... WITH FUNCTION meaning_of_life()
   ...   RETURNS tinyint
   ...   BEGIN
   ...     DECLARE a tinyint DEFAULT CAST(6 as tinyint);
   ...     DECLARE b tinyint DEFAULT CAST(7 as tinyint);
   ...     RETURN a * b;
   ...   END
   ... SELECT meaning_of_life()
   ... """, "trino")
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/__init__.py",
 line 102, in parse
       return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/dialects/dialect.py",
 line 1010, in parse
       return self.parser(**opts).parse(self.tokenize(sql), sql)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 1584, in parse
       return self._parse(
              ^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 1653, in _parse
       expressions.append(parse_method(self))
                          ^^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 1894, in _parse_statement
       expression = self._parse_set_operations(expression) if expression else 
self._parse_select()
                                                                              
^^^^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 3180, in _parse_select
       cte = self._parse_with()
             ^^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 3313, in _parse_with
       cte = self._parse_cte()
             ^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 3356, in _parse_cte
       this=self._parse_wrapped(self._parse_statement),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 7189, in _parse_wrapped
       self.raise_error("Expecting (")
     File 
"/Users/beto/.pyenv/versions/3.12.4/envs/shillelagh-3.12/lib/python3.12/site-packages/sqlglot/parser.py",
 line 1697, in raise_error
       raise error
   sqlglot.errors.ParseError: Expecting (. Line 2, Col: 29.
   
   WITH FUNCTION meaning_of_life()
     RETURNS tinyint
     BEGIN
       DECLARE a tinyint DEFAULT CAST(6 as tinyint);
       DECLARE b tinyint
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to