Skip to content

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

@andrew-oh-spare

Description

@andrew-oh-spare

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:sqlIssues related to SQL API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions