cube-js / cube-js/cube

[cubesql] SQL functions like DATE() should respect the timezone parameter passed to /v1/cubesql

Open
#10,352 0 comments 0 reactions 0 assignees View on GitHub
api:sql
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

## Description

When executing SQL queries via the /v1/cubesql HTTP endpoint with a timezone parameter, the timezone is only applied to the Cube load request but not to SQL functions like DATE(), NOW(), CURRENT_DATE, etc. that are executed within the Cube SQL layer.

## Current Behavior

When I pass a timezone to /v1/cubesql:
```
POST /v1/cubesql
{
"query": "SELECT DATE(order_date) as order_day FROM Orders",
"timezone": "America/Los_Angeles"
}
```
The DATE() function still operates in UTC, not in the specified timezone (America/Los_Angeles).

## Expected Behavior

When a timezone parameter is provided, all date/time operations in the SQL query should respect that timezone.

For example:
```
SELECT DATE(order_date) as order_day FROM Orders
```

With timezone: "America/Los_Angeles", if order_date is 2024-01-15T02:00:00Z (UTC), the DATE() function should return 2024-01-14 (since 2 AM UTC is 6 PM on Jan 14 in LA), not 2024-01-15.

**Version:**
v1.6.6.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.