Skip to content

Add Profiles Sync Sample Query #6790

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

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/unify/profiles-sync/sample-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ GROUP BY 1
SELECT * FROM ps_materialize.profile_traits WHERE merged_to IS NULL
```

### Pull the latest subscription status set for every profile identifier in the space

Provides the latest subscription status set for all identifiers in the space. This query will not include identifiers that have no subscription status ever set.

```sql
SELECT evt1.user_id, evt1.channel, evt1._id id, evt1.status, evt1.received_at
FROM ps_segment.CHANNEL_SUBSCRIPTION_UPDATED evt1
JOIN (
SELECT _id, MAX(received_at) AS max_received_at
FROM ps_segment.CHANNEL_SUBSCRIPTION_UPDATED
GROUP BY _id
) evt2
ON evt1._id = evt2._id AND evt1.received_at = evt2.max_received_at
ORDER BY 1
```

### Show all pages visited by a user

To get complete user histories, join event tables to the identity graph and aggregate or filter with `id_graph.canonical_segment_id`:
Expand Down
Loading