-
Notifications
You must be signed in to change notification settings - Fork 4
feature/:Enhanced dim_course_section to expose section_characteristics descriptors #231
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| with sections as ( | ||
| select * from {{ ref('stg_ef3__sections') }} | ||
| ), | ||
| xwalk_section_characteristics as ( | ||
| select * from {{ ref('xwalk_section_characteristics') }} | ||
| ), | ||
| flattened as ( | ||
| select | ||
| k_course_section, | ||
| {{ edu_edfi_source.extract_descriptor('section_chars.value:sectionCharacteristicDescriptor::string') }} as section_characteristic | ||
| from sections | ||
| {{ edu_edfi_source.json_flatten('v_section_characteristics', 'section_chars', outer=true) }} | ||
| ), | ||
| pivoted as ( | ||
| select | ||
| k_course_section, | ||
| {{ edu_edfi_source.json_array_agg( | ||
| 'section_characteristic', | ||
| order_by='section_characteristic', | ||
| is_terminal=True | ||
| ) }} as section_characteristics_array | ||
| {%- if not is_empty_model('xwalk_section_characteristics') -%}, | ||
| {{ ea_pivot( | ||
| column='indicator_name', | ||
| values=dbt_utils.get_column_values(ref('xwalk_section_characteristics'), 'indicator_name'), | ||
| cast='boolean', | ||
| ) }} | ||
| {%- endif %} | ||
| from flattened | ||
| left outer join xwalk_section_characteristics | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very small, picky thing, can we use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can, yes. They mean the same but I've always used the word "outer" just because in my history in IT (I'm old) I've always trained junior developers and explicitly saying "outer" has been helpful in reducing confusion. |
||
| on flattened.section_characteristic = xwalk_section_characteristics.section_characteristic_descriptor | ||
| group by all | ||
| ) | ||
| select * | ||
| from pivoted | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need the
outer=truehere? What would be the benefit of creating rows for course sections without characteristics for this model?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's needed. I'ts been awhile since I wrote this but I might have been thinking that I saw outer=true as sort of a standard you guys were doing for these things? So that maybe if you had to troubleshoot data in the table, you'd have all the rows to look at and not just the rows that contained useful data? I don't know, to be honest.