atronchi opened a new issue #9233: % interpreted as a python format character in SQLlab during CSV export URL: https://github.com/apache/incubator-superset/issues/9233 When exporting to CSV from superset's SQL editor, if the query contains any '%' characters, the export fails due to interpreting the '%' as a format character. ### Expected results CSV export should succeed regardless of the query contents. ### Actual results CSV export fails with: """ TypeError TypeError: %o format: an integer is required, not dict Traceback (most recent call last) File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__ return self.wsgi_app(environ, start_response) File "/app/.runtimes/python/lib/python3.6/site-packages/werkzeug/middleware/proxy_fix.py", line 228, in __call__ return self.app(environ, start_response) File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app response = self.handle_exception(e) File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception reraise(exc_type, exc_value, tb) File "/app/.runtimes/python/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise raise value File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "/app/.runtimes/python/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise raise value File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/app/.runtimes/python/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/app/superset/utils.py", line 928, in wraps return f(self, *args, **kwargs) File "/app/superset/models/core.py", line 1036, in wrapper value = f(*args, **kwargs) File "/app/superset/views/core.py", line 3184, in csv df = query.database.get_df(sql, query.schema) File "/app/superset/models/core.py", line 835, in get_df df = pd.read_sql_query(sqls[-1], eng) File "/app/.runtimes/python/lib/python3.6/site-packages/pandas/io/sql.py", line 332, in read_sql_query parse_dates=parse_dates, chunksize=chunksize) File "/app/.runtimes/python/lib/python3.6/site-packages/pandas/io/sql.py", line 1092, in read_query result = self.execute(*args) File "/app/.runtimes/python/lib/python3.6/site-packages/pandas/io/sql.py", line 983, in execute return self.connectable.execute(*args, **kwargs) File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2075, in execute return connection.execute(statement, *multiparams, **params) File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 942, in execute return self._execute_text(object, multiparams, params) File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1104, in _execute_text statement, parameters File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context context) File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1416, in _handle_dbapi_exception util.reraise(*exc_info) File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise raise value File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context context) File "/app/.runtimes/python/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute cursor.execute(statement, parameters) File "/app/.runtimes/python/lib/python3.6/site-packages/pyhive/presto.py", line 194, in execute sql = operation % _escaper.escape_args(parameters) TypeError: %o format: an integer is required, not dict The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side. You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection: dump() shows all variables in the frame dump(obj) dumps all that's known about the object Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter. """ #### Screenshots <img width="1009" alt="image" src="https://user-images.githubusercontent.com/4906224/75828476-c44f5b00-5d60-11ea-8c99-d15f894e73a9.png"> <img width="834" alt="image" src="https://user-images.githubusercontent.com/4906224/75828500-d3cea400-5d60-11ea-9978-66cadf8d6a69.png"> #### How to reproduce the bug 1. Go to SQLLab 2. Enter a query with '%', for example: """ SELECT bar FROM (SELECT 'foo' AS bar) subquery WHERE bar LIKE '%oo' """ 3. Run the query, then click the button to export CSV 4. See error ### Environment - python version: 3.6 Unable to verify others since this is a managed instance I don't have full access to. ### Checklist Make sure these boxes are checked before submitting your issue - thank you! - [ unable ] I have checked the superset logs for python stacktraces and included it here as text if there are any. - [ unable ] I have reproduced the issue with at least the latest released version of superset. - [ X ] I have checked the issue tracker for the same issue and I haven't found one similar.
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
