From 8dadf6ea99dfc791f41b2eabfd3399ffebf58b38 Mon Sep 17 00:00:00 2001 From: Parag Jain Date: Wed, 7 Jan 2026 18:07:15 +0530 Subject: [PATCH] duckdb range query with tz --- runtime/drivers/olap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/drivers/olap.go b/runtime/drivers/olap.go index 5d3bda909a0..8c44d32e446 100644 --- a/runtime/drivers/olap.go +++ b/runtime/drivers/olap.go @@ -650,7 +650,7 @@ func (d Dialect) SelectTimeRangeBins(start, end time.Time, grain runtimev1.TimeG case DialectDuckDB: // first convert start and end to the target timezone as the application sends UTC representation of the time, so it will send `2024-03-12T18:30:00Z` for the 13th day of March in Asia/Kolkata timezone (`2024-03-13T00:00:00Z`) // then let duckdb range over it and then convert back to the target timezone - return fmt.Sprintf("SELECT timezone('%s', range) AS %s FROM range('%s'::TIMESTAMP, '%s'::TIMESTAMP, INTERVAL '1 %s')", tz.String(), d.EscapeIdentifier(alias), start.In(tz).Format(time.DateTime), end.In(tz).Format(time.DateTime), d.ConvertToDateTruncSpecifier(grain)), nil, nil + return fmt.Sprintf("SELECT range AT TIME ZONE '%s' AS %s FROM range('%s'::TIMESTAMPTZ AT TIME ZONE '%s', '%s'::TIMESTAMPTZ AT TIME ZONE '%s', INTERVAL '1 %s')", tz.String(), d.EscapeIdentifier(alias), start.Format(time.RFC3339), tz.String(), end.Format(time.RFC3339), tz.String(), d.ConvertToDateTruncSpecifier(grain)), nil, nil case DialectClickHouse: // format - SELECT c1 AS "alias" FROM VALUES(toDateTime('2021-01-01 00:00:00'), toDateTime('2021-01-01 00:00:00'),...) var sb strings.Builder