Skip to content

Commit 9dcf531

Browse files
FujistoneJeanLouisLamezec
authored andcommitted
feat(constraints) : adding constraints and descriptive documentation to columns in demo models
fix(matomo): rm campaign_name frm matomo_campaign_source_medium fix(matomo_campaign): rm matomo_content wip feat(meetings + proposals): use new macro to check column.dtype feat(proposals): add macro to deal with old_state and state rm club_utilisateurs from ci feat(ps_belge) : adding Ps Belge dbt project feat(constraints) : adding constraints and descriptive documentation to columns in demo models feat(constraints) : removing model level constraints and adding constraints packages in demo wip feat(constraints) : removing model level constraints and adding constraints packages in demo
1 parent 5d6a244 commit 9dcf531

File tree

6 files changed

+176
-6
lines changed

6 files changed

+176
-6
lines changed

projects/demo/models/marts/categorizations/schema.yml

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
version: 2
2+
3+
models:
4+
- name: categorizations
5+
schema: "{{ env_var('TARGET_SCHEMA') }}"
6+
description: "Categories and subcategories related to categorizations on the platform"
7+
columns:
8+
- name: id
9+
description: "The unique identifier for a categorization"
10+
constraints:
11+
- type: not_null
12+
- type: unique
13+
- type: primary_key
14+
- name: category_name
15+
description: "The name of the category"
16+
- name: child_id
17+
description: "The ID of the child category (if applicable)"
18+
- name: child_name
19+
description: "The name of the child category (if applicable)"
20+
- name: categorizable_id
21+
description: "The ID of the resource being categorized (could be proposal or budget)"
22+
constraints:
23+
- type: not_null
24+
- type: foreign_key
25+
expression: "{{ target.schema }}.decidim_proposals (id)"
26+
- type: not_null
27+
- type: foreign_key
28+
expression: "{{ target.schema }}.decidim_budgets (id)"
29+
- name: categorizable_type
30+
description: "The type of resource being categorized (could be proposal or budget)"
131
unit_tests:
232
- name: testing_that_main_categories_are_properly_processed
333
description: "Checks that main categories has the correct infos "

projects/demo/models/marts/components/schema.yml

+24-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@ version: 2
33
models:
44
- name: components
55
description: "Model representing the components associated with participatory spaces in Decidim."
6+
7+
# model-level constraints
8+
constraints:
9+
- type: primary_key
10+
columns: [ id ]
11+
- type: foreign_key # multi_column
12+
columns: [ decidim_organization_id ]
13+
to: ref('organizations')
14+
to_columns: [ id ]
15+
616
columns:
717
- name: id
818
description: "Unique identifier for the component."
919
data_tests:
1020
- not_null
1121
- unique
22+
constraints:
23+
- type: not_null
24+
- type: unique
25+
- type: primary_key
1226
- name: manifest_name
1327
description: "Name of the component's manifest file. The manifest defines the component's configuration and metadata."
1428
data_tests:
@@ -25,6 +39,11 @@ models:
2539
description: "URL for accessing the component."
2640
- name: ps_id
2741
description: "Identifier of the associated participatory space."
42+
constraints:
43+
- type: not_null
44+
- type: foreign_key
45+
to: ref('stg_decidim_participatory_processes')
46+
to_columns: [ id ]
2847
- name: ps_published_at
2948
description: "Publication date of the participatory space."
3049
- name: ps_title
@@ -41,8 +60,11 @@ models:
4160
description: "URL of the participatory space."
4261
- name: decidim_organization_id
4362
description: "Identifier of the Decidim organization."
44-
data_tests:
45-
- not_null
63+
constraints:
64+
- type: not_null
65+
- type: foreign_key
66+
to: ref('organizations')
67+
to_columns: [ id ]
4668
- name: organization_host
4769
description: "Host of the Decidim organization."
4870

+39-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
11
version: 2
22

33
models:
4-
- name: forms_answers
5-
description: "Table gathering all types of answers (long, short, optional, sorting and matrix). "
4+
- name: form_answers
5+
description: "Table gathering all types of answers (short, long, optional, sorting, matrix, and file answers) submitted to forms."
66
columns:
7+
- name: decidim_user_id
8+
description: "The ID of the user who submitted the answer"
9+
constraints:
10+
- type: not_null
11+
- type: unique
12+
- type: primary_key
13+
- name: session_token
14+
description: "Session token for tracking the user's session"
15+
- name: position
16+
description: "The position of the answer in the form"
17+
- name: decidim_questionnaire_id
18+
description: "The ID of the form/questionnaire to which this answer belongs"
19+
constraints:
20+
- type: not_null
21+
- type: foreign_key
22+
expression: "{{ target.schema }}.forms (id)"
23+
- name: ip_hash
24+
description: "IP hash for tracking the user's IP address"
25+
- name: question_type
26+
description: "The type of the question (e.g., short, long, matrix)"
27+
- name: question_title
28+
description: "The title of the question being answered"
29+
- name: answer
30+
description: "The answer given by the user"
31+
- name: sub_matrix_question
32+
description: "The question for a sub-matrix (if applicable)"
33+
- name: custom_body
34+
description: "Custom text associated with the answer (if applicable)"
35+
- name: sorting_position
36+
description: "The sorting position of the answer (sorting-type questions only)"
37+
- name: form_title
38+
description: "The title of the form/questionnaire"
739
- name: sorting_points
8-
description: "In order to evaluate the weight of the sorting answers, points are given to the answer according to its sorting position."
40+
description: "Calculated sorting points based on the sorting position"
41+
- name: created_at
42+
description: "Timestamp of when the answer was created"
43+
- name: author_status
44+
description: "Status of the author "

projects/demo/models/marts/meetings/schema.yml

+65
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,71 @@ models:
55
columns:
66
- name: id
77
description: "The unique identifier for a meeting"
8+
data_tests:
9+
- not_null
10+
- unique
11+
constraints:
12+
- type: not_null
13+
- type: unique
14+
- type: primary_key
15+
- name: title
16+
description: "The title of the meeting"
17+
data_tests:
18+
- not_null
19+
constraints:
20+
- type: not_null
21+
- name: description
22+
description: "A brief description of the meeting"
23+
- name: address
24+
description: "The physical or virtual address of the meeting"
25+
- name: attendees_count
26+
description: "The total number of attendees at the meeting"
27+
- name: created_at
28+
description: "The timestamp when the meeting was created"
29+
data_tests:
30+
- not_null
31+
constraints:
32+
- type: not_null
33+
- name: decidim_scope_id
34+
description: "The identifier of the scope this meeting belongs to"
35+
constraints:
36+
- type: not_null
37+
- type: foreign_key
38+
expression: "{{ target.schema }}.decidim_scopes (id)"
39+
- name: decidim_component_id
40+
description: "The identifier of the component associated with the meeting"
41+
constraints:
42+
- type: not_null
43+
- type: foreign_key
44+
expression: "{{ target.schema }}.components (id)"
45+
- name: start_time
46+
description: "The start time of the meeting"
47+
- name: end_time
48+
description: "The end time of the meeting"
49+
- name: registration_url
50+
description: "URL for registration for the meeting"
51+
- name: type_of_meeting
52+
description: "The type/category of the meeting"
53+
- name: translated_type_of_meeting
54+
description: "The translated type of the meeting"
55+
- name: private_meeting
56+
description: "Indicates if the meeting is private"
57+
- name: decidim_author_id
58+
description: "The ID of the author or organizer of the meeting"
59+
constraints:
60+
- type: not_null
61+
- type: foreign_key
62+
expression: "{{ target.schema }}.decidim_users (id)"
63+
- name: resource_type
64+
description: "The type of resource related to the meeting"
65+
- name: meeting_url
66+
description: "The URL to access the meeting"
67+
- name: categories
68+
description: "Categories associated with the meeting"
69+
- name: sub_categories
70+
description: "Subcategories associated with the meeting"
71+
- name: categorizations
72+
description: "The full categorization data (raw) for the meeting"
873
unit_tests:
974
- name: test_url_concatenation
1075
description: "Check URL concatenation logic"

projects/demo/models/marts/proposals/schema.yml

+15
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ models:
1010
tests:
1111
- unique
1212
- not_null
13+
constraints:
14+
- type: unique
15+
- type: not_null
1316
- name: decidim_participatory_space_id
1417
description: "Identifier for the participatory space where the proposal was created"
18+
constraints:
19+
- type: not_null
20+
- type: foreign_key
21+
expression: "{{ target.schema }}.participatory_spaces (id)" # Foreign key reference to participatory_spaces table
1522
- name: decidim_participatory_space_slug
1623
description: "Slug for the participatory space where the proposal was created"
1724
- name: decidim_scope_name
@@ -26,6 +33,10 @@ models:
2633
description: "URL link to the proposal on the Decidim platform"
2734
- name: decidim_component_id
2835
description: "Identifier for the component within which the proposal was created"
36+
constraints:
37+
- type: not_null
38+
- type: foreign_key
39+
expression: "{{ target.schema }}.components (id)" # Foreign key reference to components table
2940
- name: created_at
3041
description: "Timestamp when the proposal was created"
3142
- name: published_at
@@ -38,6 +49,10 @@ models:
3849
description: "Array of IDs of the authors of the proposal"
3950
- name: first_author_id
4051
description: "ID of the first author of the proposal"
52+
constraints:
53+
- type: not_null
54+
- type: foreign_key
55+
expression: "{{ target.schema }}.users (id)" # Foreign key reference to users table
4156
- name: address
4257
description: "Address related to the proposal, if any"
4358
- name: categories

projects/demo/packages.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ packages:
22
- package: dbt-labs/dbt_utils
33
version: 1.2.0
44
- package: calogica/dbt_date
5-
version: 0.10.1
5+
version: 0.10.1
6+
- package: Snowflake-Labs/dbt_constraints
7+
version: 1.0.4

0 commit comments

Comments
 (0)