File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed
cubejs-backend-shared/src Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,10 @@ All time-based calculations performed by Cube are time zone-aware.
4646
4747By default, Cube assumes that time values in your queries (e.g., in date range
4848filters) are in the [ UTC time zone] [ wiki-utc-time-zone ] . Similarly, it will use
49- the same time zone for time dimension values in result sets.
49+ the same time zone for time dimension values in result sets. You can use the
50+ ` CUBEJS_DEFAULT_TIMEZONE ` environment variable to override it.
5051
51- You can use the ` timezone ` option with [ REST API] [ ref-rest-api-query-format-options ]
52+ You can also use the ` timezone ` option with [ REST API] [ ref-rest-api-query-format-options ]
5253or [ GraphQL API] [ ref-ref-graphql-api-args ] to specify the time zone for a query.
5354Also, you can use the [ ` SQL_UTILS ` context variable] [ ref-sql-utils ] to apply the
5455time zone conversion to dimensions that are not used as time dimensions in a query.
Original file line number Diff line number Diff line change @@ -912,6 +912,25 @@ untrusted environments.
912912
913913</WarningBox >
914914
915+ ## ` CUBEJS_DEFAULT_TIMEZONE `
916+
917+ The default [ time zone] [ ref-time-zone ] for queries.
918+
919+ | Possible Values | Default in Development | Default in Production |
920+ | ---------------------- | ---------------------- | --------------------- |
921+ | A valid time zone name | ` UTC ` | ` UTC ` |
922+
923+ You can set the time zone name in the [ TZ Database Name] [ link-tzdb ] format, e.g.,
924+ ` America/Los_Angeles ` .
925+
926+ <WarningBox >
927+
928+ Increasing the maximum row limit may cause out-of-memory (OOM) crashes and make
929+ Cube susceptible to denial-of-service (DoS) attacks if it's exposed to
930+ untrusted environments.
931+
932+ </WarningBox >
933+
915934## ` CUBEJS_DEFAULT_API_SCOPES `
916935
917936[ API scopes] [ ref-rest-scopes ] used to allow or disallow access to REST API
@@ -1881,3 +1900,5 @@ The port for a Cube deployment to listen to API connections on.
18811900[ ref-mdx-api ] : /product/apis-integrations/mdx-api
18821901[ ref-mdx-api-locale ] : /product/apis-integrations/mdx-api#measure-format
18831902[ ref-time-dimensions ] : /product/data-modeling/reference/dimensions#time
1903+ [ ref-time-zone ] : /product/apis-integrations/queries#time-zone
1904+ [ link-tzdb ] : https://en.wikipedia.org/wiki/Tz_database
Original file line number Diff line number Diff line change @@ -328,6 +328,7 @@ function normalizeQueryCacheMode(query, cacheMode) {
328328 */
329329const normalizeQuery = ( query , persistent , cacheMode ) => {
330330 query = normalizeQueryCacheMode ( query , cacheMode ) ;
331+ query . timezone = query . timezone || getEnv ( 'defaultTimezone' ) ;
331332 const { error } = querySchema . validate ( query ) ;
332333 if ( error ) {
333334 throw new UserError ( `Invalid query format: ${ error . message || error . toString ( ) } ` ) ;
Original file line number Diff line number Diff line change @@ -244,6 +244,9 @@ const variables: Record<string, (...args: any) => any> = {
244244 nestedFoldersDelimiter : ( ) => get ( 'CUBEJS_NESTED_FOLDERS_DELIMITER' )
245245 . default ( '' )
246246 . asString ( ) ,
247+ defaultTimezone : ( ) => get ( 'CUBEJS_DEFAULT_TIMEZONE' )
248+ . default ( 'UTC' )
249+ . asString ( ) ,
247250
248251 /** ****************************************************************
249252 * Common db options *
You can’t perform that action at this time.
0 commit comments