Skip to content
Open
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions models/intermediate/int_member_bookings.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
with bookings as (

select *
from {{ source('fitness_dataset', 'bookings') }}

),

members as (

select *
from {{ ref('stg_members') }}

),

joined as (

select
bookings.booking_id,
bookings.member_id,
bookings.class_id,
bookings.booking_timestamp,
bookings.attendance_status,
bookings.check_in_timestamp,
bookings.cancellation_timestamp,

members.first_name,
members.last_name,
members.email,
members.missing_email_flag,
members.date_of_birth,
members.join_date,
members.membership_status,
members.home_club

from bookings
left join members
on bookings.member_id = members.member_id

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you will need a unit test in the int_member_bookings.yml to test this logic

)

select *
from joined
62 changes: 62 additions & 0 deletions models/intermediate/int_member_bookings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: 2

models:
- name: int_member_bookings
description: "Intermediate model joining bookings to members at booking grain."

columns:
- name: booking_id
description: "Unique identifier for each booking."
tests:
- not_null
- unique

- name: member_id
description: "Unique identifier for the member linked to the booking."
tests:
- not_null

- name: class_id
description: "Unique identifier for the class linked to the booking."
tests:
- not_null

- name: booking_timestamp
description: "Timestamp when the booking was made."
tests:
- not_null

- name: attendance_status
description: "Attendance status recorded for the booking."
tests:
- not_null

- name: check_in_timestamp
description: "Timestamp when the member checked in for the class, if applicable."

- name: cancellation_timestamp
description: "Timestamp when the booking was cancelled, if applicable."

- name: first_name
description: "Member first name."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null test needed

- name: last_name
description: "Member last name."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null tests needed

- name: email
description: "Member email address."

- name: missing_email_flag
description: "True when the member email is missing or blank."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null tests needed

- name: date_of_birth
description: "Member date of birth."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null tests needed

- name: join_date
description: "Date the member joined."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null tests needed

- name: membership_status
description: "Standardised membership status from stg_members."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null tests needed

- name: home_club
description: "Member home club."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not null tests needed and maybe accepted values test

Loading