Skip to content

Grouping by utc timestamp turned into timezoned timestamp still uses utc for group #13962

Description

@TheBuilderJR

Describe the bug

For a query like this

              SELECT
                  date_trunc('${timeCoersion}', (timestamp_utc AT TIME ZONE '${timezone}')::timestamptz) AS ts_date,
                  session_id,
                  COUNT(*) AS pageviews,
                  CASE WHEN COUNT(*) = 1 THEN 1 ELSE 0 END AS is_bounce,
                  MAX(timestamp_utc) AS latest_hit_aux,
                  MIN(timestamp_utc) AS first_hit_aux
              FROM ${"_" + token.replace(/-/g, "_")}
              WHERE
                  ${processFilters(filters, useTelemetry)}
                  timestamp_utc >= TO_TIMESTAMP(${start})
                  AND timestamp_utc <= TO_TIMESTAMP(${end})
              GROUP BY
                  ts_date,
                  session_id

I would expect the group by to group by the timezone, but instead it uses utc to group by and only formats the timestamp as the timezone.

To Reproduce

Run a similar query and notice the group by is incorrect

Expected behavior

Group by using the actual timezone

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions