Skip to content
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

Feature/Contacts and StudentContactAssociations #96

Merged
merged 14 commits into from
Sep 13, 2024
Merged

Conversation

sleblanc23
Copy link
Contributor

@sleblanc23 sleblanc23 commented Jul 22, 2024

Description & motivation

In Data Standard v5.0, Parents were renamed to Contacts. The new Contact entity is identical to the previous Parent entity with the addition of an optional GenderIdentity, PreferredFirstName, and PreferredLastName fields. StudentParentAssociations was also renamed to StudentContactAssociations and the parentReference in SurveyResponses was renamed to contactReference.

This PR adds base and stage models for the new resources, which union in the data from the deprecated parent-named resources.

Breaking changes introduced by this PR:

  • stg_ef3__survey_responses now includes k_contact instead of k_parent.
  • Three new columns were added to the base and stage models for parents. These will always be null for parents but may be populated in contacts, so they are required for the union operation.

PR Merge Priority:

  • Medium

Changes to existing files:

  • gen_skey : add k_contact to key definitions
  • base_ef3__parents : add three new fields which were introduced along with the Contacts rename in order to allow the tables to be unioned in stage
  • base_ef3__survey_responses : coalesce parentReference and contactReference into a single contact_reference
  • stg_ef3__survey_responses : rename k_parent to k_contact

New files created:

Base and stage models for contacts, student_contact_associations, and unpacked contacts lists.

Tests and QC done:

Ran in Stadium SCDE; confirmed that columns were populating correctly (where data is available) and staging tables included both Parent and Contact data.

Future ToDos & Questions:

  • I think the impact of the switching to k_contact in stg_ef3__survey_responses is small, possibly none - we don't have any warehouse models for surveys yet and I didn't see the field referenced in any implementation repos.

@sleblanc23 sleblanc23 marked this pull request as ready for review July 22, 2024 21:09
@sleblanc23 sleblanc23 requested a review from rlittle08 July 22, 2024 21:11
-- we can't use the gen_skey macro here because we're bringing in the deprecated parents endpoint data, which contains a parentReference that won't work
iff(
contact_unique_id is not null,
md5(cast(coalesce(cast(tenant_code as TEXT), '') || '-' || coalesce(cast(lower(contact_unique_id) as TEXT), '') as TEXT)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you use dbt_utils.surrogate key? and what's the case where contact_unique_id is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, good call! updated to use surrogate_key. and it shouldn't ever be null, that's a mistake on my part.

{{ gen_skey('k_student_xyear') }},
api_year as school_year,
unioned.*
{{ extract_extension(model_name=this.name, flatten=True) }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this lose extensions from student_parent_associations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so because the two v_ext columns have been unioned together

Copy link
Collaborator

Choose a reason for hiding this comment

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

but I think the macro will only extract the extensions configured under this.name, which is stg_ef3__student_contact_associations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the macro can take a list of model names, so I added extensions configured under parents: {{ extract_extension([model_name=this.name, 'stg_ef3__parents'], flatten=True) }}

I don't have an implementation with extensions to test this on, but it should work based on the documentation of the macro

models/staging/edfi_3/stage/stg_ef3__contacts.sql Outdated Show resolved Hide resolved
@sleblanc23 sleblanc23 requested a review from rlittle08 July 30, 2024 18:44
@sleblanc23
Copy link
Contributor Author

@rlittle08 I added a variable that has to be set to True in implementations that want to use Contacts (to avoid a big breaking change). Current name is edu:contacts:enabled but I'm not totally sure it's the right choice.

@sleblanc23 sleblanc23 marked this pull request as draft July 30, 2024 19:52
@sleblanc23 sleblanc23 marked this pull request as ready for review August 2, 2024 20:55
@rlittle08
Copy link
Collaborator

when we merge this, add to migration notes that implementations should copy in this codegen update: https://github.com/edanalytics/edu_project_template/pull/40/files

@rlittle08 rlittle08 merged commit 4a49369 into main Sep 13, 2024
@rlittle08 rlittle08 deleted the feature/contacts branch September 13, 2024 19:30
@rlittle08 rlittle08 restored the feature/contacts branch September 16, 2024 20:58
rlittle08 added a commit that referenced this pull request Sep 19, 2024
* New DS5 optional fields for `Section`, `CourseTranscript`, and `StudentSectionAssociation` (#104)

* add section_type

* bring into line with correct json names

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* fix typo (#90)

* fix typo

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* Feature/Contacts and StudentContactAssociations (#96)

* redraft

* add student contact associations

* switch from parent to contact

* add comments about name change

* can't use gsn_skey

* add note about new fields

* update changelog

* use dbt utils surrogate key

* use parents if contacts are not enabled

* add docs

* remove configurability

* extract extenstions configured with parent naming too

* fix bad syntax

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* Bugfix/Updated Surrogate Keys to include lower() in student_unique_id inputs (#100)

* added lower to student_unique_id in surrogate keys

* Update stg_ef3__student_objective_assessments.sql

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* Feature/new DS5 optional fields on staff (#103)

* add new optional fields

* fix typo

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* flatten student cohort year (#92)

* flatten student cohort year

* grab school year and term

* rename fields

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* explicitly call extract macro from this package (#98)

* explicitly call extract macro from this package

* Update CHANGELOG.md

---------

Co-authored-by: John C. Merfeld <John.Merfeld@gmail.com>
Co-authored-by: ejoranlienea <ejoranlien@edanalytics.org>
Co-authored-by: Samantha LeBlanc <56237580+sleblanc23@users.noreply.github.com>
Co-authored-by: Angelica Lastra <107369214+AngelicaLastra@users.noreply.github.com>
Co-authored-by: keen <51969358+keenzarate213@users.noreply.github.com>
rlittle08 added a commit that referenced this pull request Sep 20, 2024
… for grading periods v5.0) (#99)

* draft of grading_period key change for v5.0

* update from main (#106)

* New DS5 optional fields for `Section`, `CourseTranscript`, and `StudentSectionAssociation` (#104)

* add section_type

* bring into line with correct json names

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* fix typo (#90)

* fix typo

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* Feature/Contacts and StudentContactAssociations (#96)

* redraft

* add student contact associations

* switch from parent to contact

* add comments about name change

* can't use gsn_skey

* add note about new fields

* update changelog

* use dbt utils surrogate key

* use parents if contacts are not enabled

* add docs

* remove configurability

* extract extenstions configured with parent naming too

* fix bad syntax

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* Bugfix/Updated Surrogate Keys to include lower() in student_unique_id inputs (#100)

* added lower to student_unique_id in surrogate keys

* Update stg_ef3__student_objective_assessments.sql

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* Feature/new DS5 optional fields on staff (#103)

* add new optional fields

* fix typo

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* flatten student cohort year (#92)

* flatten student cohort year

* grab school year and term

* rename fields

* Update CHANGELOG.md

---------

Co-authored-by: rlittle08 <rlittle@edanalytics.org>

* explicitly call extract macro from this package (#98)

* explicitly call extract macro from this package

* Update CHANGELOG.md

---------

Co-authored-by: John C. Merfeld <John.Merfeld@gmail.com>
Co-authored-by: ejoranlienea <ejoranlien@edanalytics.org>
Co-authored-by: Samantha LeBlanc <56237580+sleblanc23@users.noreply.github.com>
Co-authored-by: Angelica Lastra <107369214+AngelicaLastra@users.noreply.github.com>
Co-authored-by: keen <51969358+keenzarate213@users.noreply.github.com>

* add ods & dm version to every base table

---------

Co-authored-by: John C. Merfeld <John.Merfeld@gmail.com>
Co-authored-by: ejoranlienea <ejoranlien@edanalytics.org>
Co-authored-by: Samantha LeBlanc <56237580+sleblanc23@users.noreply.github.com>
Co-authored-by: Angelica Lastra <107369214+AngelicaLastra@users.noreply.github.com>
Co-authored-by: keen <51969358+keenzarate213@users.noreply.github.com>
@rlittle08 rlittle08 deleted the feature/contacts branch September 20, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants