GitHub user dosubot[bot] added a comment to the discussion: Issue with 
Incremental Dataset Refresh and Auto Time Grain

<!-- Answer -->
To enable Auto time grain in Superset, you need to configure the 
`TIME_GRAIN_ADDONS` and `TIME_GRAIN_ADDON_EXPRESSIONS` in the `config.py` file. 
These configurations allow you to define custom time grains and their 
corresponding SQL expressions for different database engines. Here's an example 
of how you might configure these:

```python
# superset_config.py
TIME_GRAIN_ADDONS = {
    "PT2S": "2 second",  # Example of adding a custom time grain
}

TIME_GRAIN_ADDON_EXPRESSIONS = {
    "clickhouse": {
        "PT2S": "toDateTime(intDiv(toUInt32(toDateTime({col})), 2)*2)",  # 
Custom expression for ClickHouse
    }
}
```

These configurations allow Superset to recognize and utilize custom time 
grains, which can be used in the Auto time grain feature. The default time 
grain setting that affects the Auto time grain feature is `'P1D'`, which stands 
for a period of 1 day 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/db_engine_specs/README.md)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/explore/controls.jsx)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great 
Response](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=great_response)
 | [Irrelevant 
Answer](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=irrelevant_answer)
 | [Incorrect 
Sources](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=incorrect_sources)
 | [Too 
Verbose](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=hallucination)
 | [Bug 
Report](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/c94515ec-e74a-4d4b-823b-8badc979a5e2?feedback_type=other)</sup>


GitHub link: 
https://github.com/apache/superset/discussions/33439#discussioncomment-13148219

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