GitHub user FrancescoCastaldi added a comment to the discussion: Superset is 
not able to load the result from hydrolix

The error `HdxStorageError hdx_query_timerange_required is set to true. Your 
query needs a time range filter in a WHERE clause` comes directly from the 
Hydrolix query engine (which is built on top of ClickHouse).

Hydrolix enforces partition pruning by requiring an explicit time range in 
every query hitting the partition key. Even though your virtual dataset SQL has 
a time range, when Superset Explore or a dashboard chart executes, it wraps 
your dataset in an outer subquery:
```sql
SELECT ... FROM ( <your_dataset_query> ) AS expr WHERE ...
```
If the chart query does not propagate the temporal filter properly, Hydrolix 
rejects the query at the cluster level.

Here are the two ways to resolve this:

### Solution 1: Inject Dynamic Time Range via Superset Jinja Macros 
(Recommended)
Modify your virtual dataset SQL in SQL Lab / Dataset editor so that the WHERE 
clause dynamically binds to the dashboard/chart time picker using Superset 
Jinja context:

```sql
SELECT
  toDateTime(intDiv(toUInt32(toDateTime("timestamp")), 300) * 300) AS 
"timestamp",
  countIf(location = 'session_setup' AND message = 'Session Created') AS 
"Session Created",
  countIf(solved = 1 AND verified = 1 AND location = 'game_verify') AS "Session 
Verified"
FROM "events_development"."events"
WHERE
  "timestamp" >= {% if from_dttm %} '{{ from_dttm }}' {% else %} NOW() - 
INTERVAL 1 DAY {% endif %}
  AND "timestamp" < {% if to_dttm %} '{{ to_dttm }}' {% else %} NOW() {% endif 
%}
GROUP BY
  "timestamp"
```
Ensure `ENABLE_TEMPLATE_PROCESSING = True` is enabled in `superset_config.py`. 
This guarantees that Hydrolix always receives valid partition time bounds 
inside the inner query.

### Solution 2: Disable `hdx_query_timerange_required` in Connection Settings
If your Hydrolix deployment permits unconstrained queries, you can disable this 
check for the Superset connection pool:
1. In Superset, go to **Settings -> Database Connections -> Edit Hydrolix**.
2. Expand **Advanced -> Other**.
3. Under **Engine Parameters**, add the ClickHouse session setting:
```json
{
  "connect_args": {
    "settings": {
      "hdx_query_timerange_required": 0
    }
  }
}
```
Saving this configuration overrides the peer setting and allows queries to 
execute even when time ranges are being formatted by outer chart expressions.


GitHub link: 
https://github.com/apache/superset/discussions/41395#discussioncomment-19164791

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