dosubot[bot] commented on issue #33421:
URL: https://github.com/apache/superset/issues/33421#issuecomment-2876535017

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


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