kuriancheeramelil opened a new issue #4028: SQL editor throwing can't 
deserialize google.cloud.bigquery._helpers.Row with BigQuery
URL: https://github.com/apache/incubator-superset/issues/4028
 
 
   Make sure these boxes are checked before submitting your issue - thank you!
   
   - [X] I have checked the superset logs for python stacktraces and included 
it here as text if any
   - [X] 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
   
   
   ### Superset version
   Name: superset
   Version: 0.20.6
   
   
   ### Steps to reproduce
   When a BigQuery statement is executed, its returning 
   TypeError: Unserializable object Row((29585638310174,), {u'sum__partner_id': 
0}) of type <class 'google.cloud.bigquery._helpers.Row'>
   
   The problem seems to be that the bigquery library is returning 
google.cloud.bigquery._helpers.Row as part of 
"db_engine_spec.fetch_data(cursor, query.limit)" inside superset/sql_lab.py
   
   Stacktrace
   ERROR in app: Exception on /superset/sql_json/ [POST]
   Traceback (most recent call last):
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1982, in 
wsgi_app
   response = self.full_dispatch_request()
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1614, in 
full_dispatch_request
   rv = self.handle_user_exception(e)
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1517, in 
handle_user_exception
   reraise(exc_type, exc_value, tb)
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1612, in 
full_dispatch_request
   rv = self.dispatch_request()
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1598, in 
dispatch_request
   return self.view_functions[rule.endpoint](**req.view_args)
   File 
"/usr/lib64/python2.7/site-packages/flask_appbuilder/security/decorators.py", 
line 52, in wraps
   return f(self, *args, **kwargs)
   File "/usr/lib/python2.7/site-packages/superset/models/core.py", line 848, 
in wrapper
   value = f(*args, **kwargs)
   File "/usr/lib/python2.7/site-packages/superset/views/core.py", line 2148, 
in sql_json
   return json_success(json.dumps(data, default=utils.json_iso_dttm_ser))
   File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
   sort_keys=sort_keys, **kw).encode(obj)
   File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
   chunks = self.iterencode(o, _one_shot=True)
   File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
   return _iterencode(o, 0)
   File "/usr/lib/python2.7/site-packages/superset/utils.py", line 303, in 
json_iso_dttm_ser
   "Unserializable object {} of type {}".format(obj, type(obj)))
   TypeError: Unserializable object Row((29585638310174,), {u'sum__partner_id': 
0}) of type <class 'google.cloud.bigquery._helpers.Row'>
   Exception on /superset/sql_json/ [POST]
   Traceback (most recent call last):
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1982, in 
wsgi_app
   response = self.full_dispatch_request()
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1614, in 
full_dispatch_request
   rv = self.handle_user_exception(e)
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1517, in 
handle_user_exception
   reraise(exc_type, exc_value, tb)
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1612, in 
full_dispatch_request
   rv = self.dispatch_request()
   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1598, in 
dispatch_request
   return self.view_functions[rule.endpoint](**req.view_args)
   File 
"/usr/lib64/python2.7/site-packages/flask_appbuilder/security/decorators.py", 
line 52, in wraps
   return f(self, *args, **kwargs)
   File "/usr/lib/python2.7/site-packages/superset/models/core.py", line 848, 
in wrapper
   value = f(*args, **kwargs)
   File "/usr/lib/python2.7/site-packages/superset/views/core.py", line 2148, 
in sql_json
   return json_success(json.dumps(data, default=utils.json_iso_dttm_ser))
   File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
   sort_keys=sort_keys, **kw).encode(obj)
   File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
   chunks = self.iterencode(o, _one_shot=True)
   File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
   return _iterencode(o, 0)
   File "/usr/lib/python2.7/site-packages/superset/utils.py", line 303, in 
json_iso_dttm_ser
   "Unserializable object {} of type {}".format(obj, type(obj)))
   TypeError: Unserializable object Row((29585638310174,), {u'sum__partner_id': 
0}) of type <class 'google.cloud.bigquery._helpers.Row'>
   
   We added the following code in superset/sql_lab.py and its working.
   data = db_engine_spec.fetch_data(cursor, query.limit)
   if len(data) != 0 and isinstance(data[0],Row):
       data = [r.values() for r in data]
   
   We are using pybigquery-0.2.3 along with superset for accessing BigQuery.
   
   Could you advise if what we are doing is correct or not. If not where the 
change has to be done to fix this error.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to