-
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.
Add a test describing payments -> persons -> events
- Loading branch information
1 parent
1181b95
commit de82d67
Showing
1 changed file
with
29 additions
and
7 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 |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
OBJECT_STORAGE_SECRET_ACCESS_KEY, | ||
XDIST_SUFFIX, | ||
) | ||
from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events | ||
from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event, _create_person, flush_persons_and_events | ||
from freezegun import freeze_time | ||
from typing import cast | ||
from django.utils import timezone | ||
|
@@ -135,12 +135,20 @@ def create_data_warehouse_table_with_payments(self): | |
datetime(2023, 1, 7), | ||
] | ||
) | ||
distinct_id = pa.array(["user_control_0", "user_test_1", "user_test_2", "user_test_3", "user_extra"]) | ||
email = pa.array( | ||
[ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
) | ||
amount = pa.array([100, 50, 75, 80, 90]) | ||
names = ["id", "dw_timestamp", "dw_distinct_id", "amount"] | ||
names = ["id", "dw_timestamp", "dw_email", "amount"] | ||
|
||
pq.write_to_dataset( | ||
pa.Table.from_arrays([id, timestamp, distinct_id, amount], names=names), | ||
pa.Table.from_arrays([id, timestamp, email, amount], names=names), | ||
path_to_s3_object, | ||
filesystem=fs, | ||
use_dictionary=True, | ||
|
@@ -164,7 +172,7 @@ def create_data_warehouse_table_with_payments(self): | |
columns={ | ||
"id": "String", | ||
"dw_timestamp": "DateTime64(3, 'UTC')", | ||
"dw_distinct_id": "String", | ||
"dw_email": "String", | ||
"amount": "Int64", | ||
}, | ||
credential=credential, | ||
|
@@ -173,7 +181,16 @@ def create_data_warehouse_table_with_payments(self): | |
DataWarehouseJoin.objects.create( | ||
team=self.team, | ||
source_table_name=table_name, | ||
source_table_key="dw_distinct_id", | ||
source_table_key="dw_email", | ||
joining_table_name="persons", | ||
joining_table_key="properties.email", | ||
field_name="persons", | ||
) | ||
|
||
DataWarehouseJoin.objects.create( | ||
team=self.team, | ||
source_table_name="persons", | ||
source_table_key="id", | ||
joining_table_name="events", | ||
joining_table_key="distinct_id", | ||
field_name="events", | ||
|
@@ -504,7 +521,7 @@ def test_query_runner_with_data_warehouse_series(self): | |
series=[ | ||
DataWarehouseNode( | ||
id=table_name, | ||
distinct_id_field="dw_distinct_id", | ||
distinct_id_field="persons.id", | ||
id_field="id", | ||
table_name=table_name, | ||
timestamp_field="dw_timestamp", | ||
|
@@ -533,6 +550,11 @@ def test_query_runner_with_data_warehouse_series(self): | |
properties={feature_flag_property: variant}, | ||
timestamp=datetime(2023, 1, i + 1), | ||
) | ||
_create_person( | ||
team=self.team, | ||
distinct_ids=[f"user_{variant}_{i}"], | ||
properties={"email": f"user_{variant}_{i}@example.com"}, | ||
) | ||
|
||
# "user_test_3" first exposure (feature_flag_property="control") is on 2023-01-03 | ||
# "user_test_3" relevant exposure (feature_flag_property="test") is on 2023-01-04 | ||
|