Skip to content

Commit

Permalink
bug: fix bug with etc/unknown timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeelaudibert committed Nov 27, 2024
1 parent aae7f7d commit 2e8a4a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion posthog/hogql_queries/web_analytics/stats_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def _counts_breakdown_value(self):
# Get the difference between the UNIX timestamp at UTC and the UNIX timestamp at the event's timezone
# Value is in milliseconds, turn it to hours, works even for fractional timezone offsets (I'm looking at you, Australia)
return parse_expr(
"if(or(isNull(properties.$timezone), empty(properties.$timezone)), NULL, (toUnixTimestamp64Milli(parseDateTimeBestEffort(assumeNotNull(toString(timestamp, properties.$timezone)))) - toUnixTimestamp64Milli(timestamp)) / 3600000)"
"if(or(isNull(properties.$timezone), empty(properties.$timezone), properties.$timezone == 'Etc/Unknown'), NULL, (toUnixTimestamp64Milli(parseDateTimeBestEffort(assumeNotNull(toString(timestamp, properties.$timezone)))) - toUnixTimestamp64Milli(timestamp)) / 3600000)"
)
case _:
raise NotImplementedError("Breakdown not implemented")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,15 @@ def test_timezone_filter_with_empty_timezone(self):
properties={"$session_id": sid, "$pathname": f"/path1", "$timezone": ""},
)

# Key exists, it's set to the invalid 'Etc/Unknown' timezone
_create_event(
team=self.team,
event="$pageview",
distinct_id=did,
timestamp=f"2019-02-17 00:00:00",
properties={"$session_id": sid, "$pathname": f"/path1", "$timezone": "Etc/Unknown"},
)

results = self._run_web_stats_table_query(
"all",
None,
Expand Down

0 comments on commit 2e8a4a3

Please sign in to comment.