Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change timestamps to be timezone aware upon parsing #11935

Merged
merged 102 commits into from
Oct 12, 2022

Conversation

EDsCODE
Copy link
Member

@EDsCODE EDsCODE commented Sep 22, 2022

Problem

  • WIP: changing how timestamps are handled as discussed Trends date buckets may be incorrect for non-utc timezones #11492
  • Main idea: any timestamps sent from the client will be interpreted as under the timezone that the team has set. The date arguments in clickhouse will include timezones so clickhouse can automatically handle the date conversion when comparing UTC vs any other timezone
  • the timestamps returned from clickhouse should be in the team timezone once again and returned to the client

key changes:

  • every toDateTime in a query that is using a client parameter should have timezone included
  • all timestamp handling should happen within querydaterange
  • filter's date_to and date_from should begin being phased out

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

How did you test this code?

@@ -176,9 +173,11 @@ def _get_timezone_aware_date_condition(self, operator: str, date_clause: str) ->
# Convert target to UTC so that stored timestamps can be compared accordingly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of date? Now we're treating target as team timezone

@@ -211,8 +211,8 @@ def get_event_query(self) -> Tuple[str, Dict[str, Any]]:
query = f"""
WITH
funnel_actors as ({funnel_persons_query}),
toDateTime(%(date_to)s) AS date_to,
toDateTime(%(date_from)s) AS date_from,
toDateTime(%(date_to)s, %(timezone)s) AS date_to,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funnel correlations should have toTimeZone here as well?

@EDsCODE EDsCODE merged commit 106db86 into master Oct 12, 2022
@EDsCODE EDsCODE deleted the refactor-timestamp-handling-scheme branch October 12, 2022 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants