GitHub user FrancescoCastaldi added a comment to the discussion: 'dict' object 
has no attribute 'set'

In Python, dictionary objects do not have a `.set()` method (that is a 
JavaScript Map or Set method). In Superset SQL Lab, this error is typically 
triggered during query parameter parsing or Jinja macro evaluation.

Here are the two most common causes and how to fix them:

### 1. Incorrect Jinja Template Syntax in the SQL Editor
If `ENABLE_TEMPLATE_PROCESSING` is enabled, Superset evaluates any curly braces 
`{...}` through its Jinja rendering engine (`superset/jinja_context.py`).

If your SQL query contains syntax attempting to set variables or mutate 
parameters like:
```jinja
-- Incorrect:
{{ params.set('key', 'val') }}
-- or passing dict methods:
{{ my_dict.set(...) }}
```
Jinja will evaluate that expression against the underlying Python dictionary 
and raise `'dict' object has no attribute 'set'`.

In Jinja, variable assignment must use the `{% set ... %}` tag statement, not 
variable interpolation:
```jinja
-- Correct syntax:
{% set my_variable = 'value' %}
SELECT * FROM my_table WHERE column_name = '{{ my_variable }}'
```

### 2. Malformed Parameters in the Parameters Modal
In SQL Lab, there is a **Parameters** button (or expandable accordion) that 
accepts JSON parameters used by Jinja.

Ensure that the JSON inside the Parameters modal is valid JSON:
```json
{
  "start_date": "2026-01-01",
  "threshold": 100
}
```
If you accidentally passed a parameter whose value is referenced in your SQL 
with a `.set(...)` method call, replace it with standard dictionary key lookup:
```jinja
{{ params['start_date'] }}
```

If your query contains database-specific SQL functions that use curly braces 
(such as JSON extraction syntax in PostgreSQL or Trino), escape them in Jinja 
using `{% raw %}` and `{% endraw %}` so Superset does not attempt to evaluate 
them as Python code.


GitHub link: 
https://github.com/apache/superset/discussions/40574#discussioncomment-19164775

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to