yousoph opened a new pull request, #41099:
URL: https://github.com/apache/superset/pull/41099

   ### Summary
   
   When a database driver returns Python `dict` or `list` objects as cell 
values (e.g. ClickHouse's native JSON and Map types via clickhouse-connect), 
Superset's `stringify_values()` in `result_set.py` converted them via 
`obj.astype(str)`, which calls Python's `str()` built-in and produces 
single-quoted repr:
   
   ```
   {'a': {'b': 42}, 'c': [1, 2, 3]}
   ```
   
   This is not valid JSON. The SQL Lab cell viewer calls 
`safeJsonObjectParse()` (which uses `JSONbig.parse()` internally) on cell 
values — it fails silently on single-quoted strings, so the interactive tree 
viewer never activates for those cells.
   
   The fix: in `stringify_values()`, when the extracted Python value is a 
`dict` or `list`, use the existing `stringify()` helper (which calls 
`json.dumps`) to produce valid double-quoted JSON:
   
   ```
   {"a": {"b": 42}, "c": [1, 2, 3]}
   ```
   
   This makes the cell viewer work for ClickHouse native JSON/Map columns and 
any other driver that returns dict/list objects.
   
   ### Reproduction
   
   Using ClickHouse 25.3+ with either `clickhouse-connect` or 
`clickhouse-sqlalchemy`:
   
   ```sql
   WITH '{"a":{"b":42},"c":[1,2,3]}'::JSON AS json
   SELECT json, json::String
   ```
   
   Before: clicking the `json` cell opens nothing. After: opens the interactive 
tree viewer.
   
   ### Testing
   
   - 
`tests/unit_tests/result_set_test.py::test_stringify_values_dict_and_list_produce_valid_json`
 — unit test for the `stringify_values` change
   - 
`tests/unit_tests/result_set_test.py::test_clickhouse_json_column_in_pa_table_is_valid_json`
 — integration-style test using `SupersetResultSet` with ClickHouse-style dict 
rows
   
   ### Checklist
   
   - [x] Unit tests added/updated
   - [x] All existing `result_set_test.py` tests pass
   - [x] No frontend changes required — fix is entirely in the serialization 
path


-- 
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]

Reply via email to