chshedra opened a new issue, #31853: URL: https://github.com/apache/superset/issues/31853
### Bug description After installing Superset version 4.1.1 with the [sqlalchemy-mongobi](https://github.com/smarzola/sqlalchemy-mongobi) connector (a simple wrapper for mysqlclient), I encountered an error when attempting to create a dataset from a table with a numeric name. The error message is: `Unable to load columns for the selected table. Please select a different table.` `sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 1, Col: 24. SELECT * FROM database.`6` LIMIT 100` This issue seems to arise due to the backtick (`) usage. Queries in SQL Lab page fail when table names are wrapped in backtick, regardless of whether the table name is numeric or not. Notably, this issue was not present in Superset 4.0.0 and earlier with the same setup. Workaround: A temporary fix involves manually changing the base dialect to MySQL dialect in the `_parse` function in superset/sql/parse.py at line 256: `return sqlglot.parse(script, dialect=dialect)` -> `return sqlglot.parse(script, dialect=Dialects.MYSQL)` While this resolves the issue, it’s not an appropriate long-term solution. Steps to Reproduce (Datasets): 1. Use sqlalchemy-mongobi with the MongoBI connector (or any other database using the base dialect) in Superset (select "Other" database in dropdown). 2. Go to Datasets and create a new dataset from a table with a numeric name. 3. The following error is displayed: "Unable to load columns for the selected table. Please select a different table." Steps to Reproduce (SQL Lab): 1. Use sqlalchemy-mongobi with the MongoBI connector (or any other database using the base dialect) in Superset (select "Other" database in dropdown). 2. Navigate to the SQL Lab page. 3. Run a query with the table name wrapped in backticks. For example: SELECT * FROM database.\1` or `SELECT * FROM database.\tablename`` 4. The following error is displayed: "This database does not allow for DDL/DML, and the query could not be parsed to confirm it is a read-only query." Superset should handle table names with numeric values wrapped with backtick without throwing errors. ### Screenshots/recordings   ### Superset version master / latest-dev ### Python version 3.9 ### Node version 16 ### Browser Chrome ### Additional context Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps return f(self, *args, **kwargs) File "/app/superset/views/base_api.py", line 119, in wraps duration, response = time_function(f, self, *args, **kwargs) File "/app/superset/utils/core.py", line 1364, in time_function response = func(*args, **kwargs) File "/app/superset/utils/log.py", line 303, in wrapper value = f(*args, **kwargs) File "/app/superset/databases/api.py", line 1024, in table_metadata payload = database.db_engine_spec.get_table_metadata(database, table) File "/app/superset/db_engine_specs/base.py", line 1079, in get_table_metadata return get_table_metadata(database, table) File "/app/superset/databases/utils.py", line 100, in get_table_metadata "selectStar": database.select_star( File "/app/superset/models/core.py", line 719, in select_star return self.db_engine_spec.select_star( File "/app/superset/db_engine_specs/base.py", line 1689, in select_star sql = SQLScript(sql, engine=cls.engine).format() File "/app/superset/sql/parse.py", line 613, in __init__ self.statements = statement_class.split_script(script, engine) File "/app/superset/sql/parse.py", line 318, in split_script ast = cls._parse(remainder, engine)[0] File "/app/superset/sql/parse.py", line 261, in _parse raise SupersetParseError( superset.exceptions.SupersetParseError: Error parsing near '6' at line 2:23 ### Checklist - [x] I have searched Superset docs and Slack and didn't find a solution to my problem. - [x] I have searched the GitHub issue tracker and didn't find a similar bug report. - [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section. -- 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]
