Redash: Object of type OrderedMapSerializedKey is not JSON serializable

Created on 31 May 2020  路  4Comments  路  Source: getredash/redash

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,
    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.

  • Redash Version:
    preview
  • Browser/OS:
    Chrome
  • How did you install Redash:
    AMI+ docker-compose from preview image.

Most helpful comment

@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.

All 4 comments

any updates on this ?

@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.

@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.

@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.

Was this page helpful?
0 / 5 - 0 ratings