getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
http://redash.io/
BSD 2-Clause "Simplified" License
25.99k stars 4.34k forks source link

Object of type OrderedMapSerializedKey is not JSON serializable #4931

Open skaravad opened 4 years ago

skaravad commented 4 years ago

Issue Summary

Used redash preview (support for cassandra tls) , we do have map type data in cassadra, when selecting data from these data types, we see an exception TypeError: Object of type OrderedMapSerializedKey is not JSON serializable

Steps to Reproduce

  1. In cassandra create table with map type column CREATE TABLE maptypeData ( customer_id text, meta_string map<text, text>, PRIMARY KEY (customer_id) );

  2. Insert data insert into maptypeData (customer_id,meta_string) values ('dummy',{'bucketName': 'testbucket', 'objectExposure': 'public', 'owner': 'dummy'});

  3. from CQLSH select * from maptypeData; customer_id | meta_string -------------+---------------------------------------------------------------------------- dummy | {'bucketName': 'testbucket', 'objectExposure': 'public', 'owner': 'dummy'}

  4. From redash UI, run the same query Result: None Error: Error running query: Object of type OrderedMapSerializedKey is not JSON serializable

Logs: xecute_query job.id=11203a82-e06a-4622-93e7-3a3ce59a71de Unexpected error while running query: Traceback (most recent call last): File "/app/redash/tasks/queries/execution.py", line 175, in run data, error = query_runner.run_query(annotated_query, self.user) File "/app/redash/query_runner/cass.py", line 165, in run_query json_data = json_dumps(data, cls=CassandraJSONEncoder) File "/app/redash/utils/init.py", line 121, in json_dumps return simplejson.dumps(data, *args, kwargs) File "/usr/local/lib/python3.7/site-packages/simplejson/init.py", line 399, in dumps kw).encode(obj) File "/usr/local/lib/python3.7/site-packages/simplejson/encoder.py", line 296, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/local/lib/python3.7/site-packages/simplejson/encoder.py", line 378, in iterencode return _iterencode(o, 0) File "/app/redash/query_runner/cass.py", line 36, in default return super(CassandraJSONEncoder, self).default(o) File "/app/redash/utils/init.py", line 103, in default result = super(JSONEncoder, self).default(o) File "/usr/local/lib/python3.7/site-packages/simplejson/encoder.py", line 273, in default o.class.name) TypeError: Object of type OrderedMapSerializedKey is not JSON serializable

Technical details:

The line numbers in the exception might not be accurate as I was trying to debug the issue.

skaravad commented 4 years ago

any updates on this ?

tim5go commented 4 years ago

@skaravad I've created a fork / PR for that. It would be nice if you can help me to do some end-to-end testings on your side.

sidvenu commented 3 years ago

@tim5go our org needs this as well, it would be kind of you if you can let me know how I can help you in getting this tested.

tim5go commented 3 years ago

@sidvenu I have created a fork on https://github.com/tim5go/redash/tree/bug/cassandra-json-serialization and PR on https://github.com/getredash/redash/pull/5185

Feel free to clone it, test it if the bug is gone when you connect to your own Cassandra database.

tncn1122 commented 10 months ago

i have same issue, i cannot use json.dumps for 'cassandra.util.OrderedMapSerializedKey'