-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix column order difference between creation and migration
- Loading branch information
Showing
3 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from posthog.clickhouse.client import sync_execute | ||
from posthog.models.raw_sessions.sql import RAW_SESSION_TABLE_BACKFILL_SELECT_SQL | ||
from posthog.models.utils import uuid7 | ||
from posthog.test.base import ( | ||
_create_event, | ||
ClickhouseTestMixin, | ||
BaseTest, | ||
) | ||
|
||
distinct_id_counter = 0 | ||
session_id_counter = 0 | ||
|
||
|
||
def create_distinct_id(): | ||
global distinct_id_counter | ||
distinct_id_counter += 1 | ||
return f"d{distinct_id_counter}" | ||
|
||
|
||
def create_session_id(): | ||
global session_id_counter | ||
session_id_counter += 1 | ||
return str(uuid7(random=session_id_counter)) | ||
|
||
|
||
class TestRawSessionsModel(ClickhouseTestMixin, BaseTest): | ||
def test_backfill_sql(self): | ||
distinct_id = create_distinct_id() | ||
session_id = create_session_id() | ||
_create_event( | ||
team=self.team, | ||
event="$pageview", | ||
distinct_id=distinct_id, | ||
properties={"$current_url": "/", "$session_id": session_id}, | ||
timestamp="2024-03-08", | ||
) | ||
|
||
# just test that the backfill SQL can be run without error | ||
sync_execute( | ||
"INSERT INTO raw_sessions" + RAW_SESSION_TABLE_BACKFILL_SELECT_SQL() + "AND team_id = %(team_id)s", | ||
{"team_id": self.team.id}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters