Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/pages/product/apis-integrations/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ All time-based calculations performed by Cube are time zone-aware.

By default, Cube assumes that time values in your queries (e.g., in date range
filters) are in the [UTC time zone][wiki-utc-time-zone]. Similarly, it will use
the same time zone for time dimension values in result sets.
the same time zone for time dimension values in result sets. You can use the
`CUBEJS_DEFAULT_TIMEZONE` environment variable to override it.

You can use the `timezone` option with [REST API][ref-rest-api-query-format-options]
You can also use the `timezone` option with [REST API][ref-rest-api-query-format-options]
or [GraphQL API][ref-ref-graphql-api-args] to specify the time zone for a query.
Also, you can use the [`SQL_UTILS` context variable][ref-sql-utils] to apply the
time zone conversion to dimensions that are not used as time dimensions in a query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,25 @@ untrusted environments.

</WarningBox>

## `CUBEJS_DEFAULT_TIMEZONE`

The default [time zone][ref-time-zone] for queries.

| Possible Values | Default in Development | Default in Production |
| ---------------------- | ---------------------- | --------------------- |
| A valid time zone name | `UTC` | `UTC` |

You can set the time zone name in the [TZ Database Name][link-tzdb] format, e.g.,
`America/Los_Angeles`.

<WarningBox>

Increasing the maximum row limit may cause out-of-memory (OOM) crashes and make
Cube susceptible to denial-of-service (DoS) attacks if it's exposed to
untrusted environments.

</WarningBox>

## `CUBEJS_DEFAULT_API_SCOPES`

[API scopes][ref-rest-scopes] used to allow or disallow access to REST API
Expand Down Expand Up @@ -1881,3 +1900,5 @@ The port for a Cube deployment to listen to API connections on.
[ref-mdx-api]: /product/apis-integrations/mdx-api
[ref-mdx-api-locale]: /product/apis-integrations/mdx-api#measure-format
[ref-time-dimensions]: /product/data-modeling/reference/dimensions#time
[ref-time-zone]: /product/apis-integrations/queries#time-zone
[link-tzdb]: https://en.wikipedia.org/wiki/Tz_database
1 change: 1 addition & 0 deletions packages/cubejs-api-gateway/src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ function normalizeQueryCacheMode(query, cacheMode) {
*/
const normalizeQuery = (query, persistent, cacheMode) => {
query = normalizeQueryCacheMode(query, cacheMode);
query.timezone = query.timezone || getEnv('defaultTimezone');
const { error } = querySchema.validate(query);
if (error) {
throw new UserError(`Invalid query format: ${error.message || error.toString()}`);
Expand Down
3 changes: 3 additions & 0 deletions packages/cubejs-backend-shared/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ const variables: Record<string, (...args: any) => any> = {
nestedFoldersDelimiter: () => get('CUBEJS_NESTED_FOLDERS_DELIMITER')
.default('')
.asString(),
defaultTimezone: () => get('CUBEJS_DEFAULT_TIMEZONE')
.default('UTC')
.asString(),

/** ****************************************************************
* Common db options *
Expand Down
Loading