francisco-pjbank opened a new issue #16373:
URL: https://github.com/apache/superset/issues/16373
Getting error when superset tries to retrieve saved queries: Table is not
serializable, when launching superset using superset run or gunicorn. My tables
are stored in S3 and I use Athena API to query them.
I launched superset with no tables previously stored and no examples.
### Expected results
It should show an empty screen with no queries and it should be possible to
add a query to the list of saved ones.
### Actual results
I can not add a query to list of saved ones and the screen below appears.
Furthermore, an exception error is thrown on command line:
```
2021-08-19 15:19:28,263:INFO:werkzeug:127.0.0.1 - - [19/Aug/2021 15:19:28]
"GET /api/v1/saved_query/related/database?q=() HTTP/1.1" 200 -
2021-08-19 15:19:28,286:ERROR:root:Object of type Table is not JSON
serializable
Traceback (most recent call last):
File
"/usr/local/lib/python3.8/dist-packages/flask_appbuilder/api/__init__.py", line
85, in wraps
return f(self, *args, **kwargs)
File
"/usr/local/lib/python3.8/dist-packages/flask_appbuilder/api/__init__.py", line
155, in wraps
return f(self, *args, **kwargs)
File
"/usr/local/lib/python3.8/dist-packages/flask_appbuilder/api/__init__.py", line
1592, in get_list
return self.get_list_headless(**kwargs)
File "/usr/local/lib/python3.8/dist-packages/superset/utils/log.py", line
228, in wrapper
value = f(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/superset/views/base_api.py",
line 406, in get_list_headless
duration, response = time_function(super().get_list_headless, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/superset/utils/core.py", line
1407, in time_function
response = func(*args, **kwargs)
File
"/usr/local/lib/python3.8/dist-packages/flask_appbuilder/api/__init__.py", line
1498, in get_list_headless
return self.response(200, **_response)
File
"/usr/local/lib/python3.8/dist-packages/flask_appbuilder/api/__init__.py", line
672, in response
_ret_json = jsonify(kwargs)
File
"/home/ubuntu/.local/lib/python3.8/site-packages/flask/json/__init__.py", line
321, in jsonify
dumps(data, indent=indent, separators=separators) + '\n',
File
"/home/ubuntu/.local/lib/python3.8/site-packages/flask/json/__init__.py", line
179, in dumps
rv = _json.dumps(obj, **kwargs)
File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 385, in
dumps
return cls(
File "/usr/lib/python3/dist-packages/simplejson/encoder.py", line 296, in
encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3/dist-packages/simplejson/encoder.py", line 378, in
iterencode
return _iterencode(o, 0)
File
"/home/ubuntu/.local/lib/python3.8/site-packages/flask/json/__init__.py", line
81, in default
return _json.JSONEncoder.default(self, o)
File "/usr/lib/python3/dist-packages/simplejson/encoder.py", line 272, in
default
raise TypeError('Object of type %s is not JSON serializable' %
TypeError: Object of type Table is not JSON serializable
```
I did follow PR #14627 guidelines but it didn't fix the problem. I checked
StackOverflow and it looks like the problem may be irelated to the fact that
flask is unable to [serialize SQLAchemy
](https://stackoverflow.com/questions/5022066/how-to-serialize-sqlalchemy-result-to-json)
objects using simplejson only . Someone suggested using
[Flask-Marshmelow](https://www.youtube.com/watch?v=kRNXKzfYrPU) to overcome
this problem.
#### Screenshots

#### How to reproduce the bug
Reproducing Exception:
1. Go to SQL Lab-> Saved Queries
2. or press F5 to reload page
(http://localhost:8088/savedqueryview/list/?pageIndex=0&sortColumn=changed_on_delta_humanized&sortOrder=desc)
Unable to add query:
1. On the page of saved queries click '+ QUERY' button. Screen shown in
screenshot appears.
### Environment
(please complete the following information):
- superset version: `1.2.0`
- python version: `3.8`
- node.js version: `v10.19.0`
- any feature flags active: only the ones below
-DEFAULT_FEATURE_FLAGS: Dict[str, bool] = {
"ENABLE_REACT_CRUD_VIEWS": True,
"DISPLAY_MARKDOWN_HTML": True,
"ROW_LEVEL_SECURITY": True,
"ALERT_REPORTS": True,
"ALERTS_ATTACH_REPORTS": True,
}
### Checklist
Make sure to follow these steps before submitting your issue - thank you!
- [OK] I have checked the superset logs for python stacktraces and included
it here as text if there are any.
- [OK] I have reproduced the issue with at least the latest released version
of superset.
- [FOUND] I have checked the issue tracker for the same issue and I haven't
found one similar.
### Additional context
Running superset with: superset run -h 127.0.0.1 -p 8088 --with-threads
--reload --debugger
No examples loaded.
Activated access to athena databases
--
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]