Get help from the marimo community

Updated 6 days ago

JSON Transform Schema makes query fail

At a glance

The community member posted a DuckDB example from the documentation that fails with a ValueError. Another community member suggests that the issue is due to the use of f-strings in mo.sql, and recommends replacing { with {{ as a workaround. The second comment expresses a desire for an option to disable the f-string behavior in mo.sql and SQL code blocks.

Useful resources
https://duckdb.org/docs/stable/data/json/json_functions.html#json-scalar-functions

Plain Text
CREATE TABLE example (j JSON);
INSERT INTO example VALUES
    ('{ "family": "anatidae", "species": [ "duck", "goose", "swan", null ] }');


This example straight from the docs fails with

Plain Text
ValueError
This cell raised an exception: ValueError('Invalid format specifier ' "anatidae", "species": [ "duck", "goose", "swan", null ] ' for object of type 'str'')

See the console area for a traceback.
Marked as solution
Ah this is because we use f strings for mo.sql I think … we should likely make that configurable. For now if you replace { with {{ I think it will work, same for }
View full solution
A
c
2 comments
Ah this is because we use f strings for mo.sql I think … we should likely make that configurable. For now if you replace { with {{ I think it will work, same for }
a lot of the time im doing SQL exploration I just want the duckdb query to work as is. an option for mo.sql and the SQL code blocks to not be f strings would be super helpful
Add a reply
Sign up and join the conversation on Discord