-
Notifications
You must be signed in to change notification settings - Fork 0
feat(elt-pipelines): Port opralogweb to elt-pipelines #462
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0205247
Add setup tools for package installation
ambolt314 93524ea
create accelerator sources file
ambolt314 9095593
migrate additional columns table to elt
ambolt314 5e4e31a
migrate chapter entry table to elt
ambolt314 63ebcbc
migrate entries table to elt
ambolt314 c450bd5
migrate logbook chapter to elt
ambolt314 af3a2a8
migrate logbooks to elt
ambolt314 d542512
migrate more entry columns to elt
ambolt314 418ada1
migrate mcr equiment downtime to elt
ambolt314 af2583a
corrected nomenclature; add base directory. References https://github…
ambolt314 2ab568a
Corrected .yml configuration; copied files instead of moving them
ambolt314 512a341
Revert warehouse changes, referencing https://github.com/ISISNeutronM…
ambolt314 7a943b1
remove newer mcr downtime files, resolving duplication error
ambolt314 3e3a3c9
Corrected file naming for elt-pipeline views
ambolt314 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
elt-pipelines/facility_ops/transform/models/staging/accelerator/_accelerator__sources.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| version: 2 | ||
|
|
||
| sources: | ||
| - name: accelerator_opralogweb | ||
| database: facility_ops_landing | ||
| tables: | ||
| - name: AdditionalColumns | ||
| - name: ChapterEntry | ||
| - name: Entries | ||
| - name: LogBookChapter | ||
| - name: Logbooks | ||
| - name: MoreEntryColumns |
22 changes: 22 additions & 0 deletions
22
...ity_ops/transform/models/staging/accelerator/base/base_opralogweb__additional_columns.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| with | ||
|
|
||
| source as ( | ||
|
|
||
| select * from {{ source('accelerator_opralogweb', 'AdditionalColumns') }} | ||
|
|
||
| ), | ||
|
|
||
| renamed as ( | ||
|
|
||
| select | ||
|
|
||
| AdditionalColumnId as additional_column_id, | ||
| trim(ColTitle) as column_title | ||
|
|
||
| from | ||
|
|
||
| source | ||
|
|
||
| ) | ||
|
|
||
| select * from renamed |
7 changes: 7 additions & 0 deletions
7
...ity_ops/transform/models/staging/accelerator/base/base_opralogweb__additional_columns.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| models: | ||
| - name: base_opralogweb__additional_columns | ||
| description: Opralogweb additional_columns table with basic cleaning | ||
| columns: | ||
| - name: additional_column_id | ||
| tests: | ||
| - not_null | ||
24 changes: 24 additions & 0 deletions
24
...facility_ops/transform/models/staging/accelerator/base/base_opralogweb__chapter_entry.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| with | ||
|
|
||
| source as ( | ||
|
|
||
| select * from {{ source('accelerator_opralogweb', 'ChapterEntry') }} | ||
|
|
||
| ), | ||
|
|
||
| renamed as ( | ||
|
|
||
| select | ||
|
|
||
| EntryId as entry_id, | ||
| PrincipalLogbook as principal_logbook, | ||
| LogbookChapterNo as logbook_chapter_no, | ||
| LogbookId as logbook_id | ||
|
|
||
| from | ||
|
|
||
| source | ||
|
|
||
| ) | ||
|
|
||
| select * from renamed |
7 changes: 7 additions & 0 deletions
7
...facility_ops/transform/models/staging/accelerator/base/base_opralogweb__chapter_entry.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| models: | ||
| - name: base_opralogweb__chapter_entry | ||
| description: Opralogweb chapter_entry table with basic cleaning | ||
| columns: | ||
| - name: entry_id | ||
| tests: | ||
| - not_null |
26 changes: 26 additions & 0 deletions
26
...lines/facility_ops/transform/models/staging/accelerator/base/base_opralogweb__entries.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| with | ||
|
|
||
| source as ( | ||
|
|
||
| select * from {{ source('accelerator_opralogweb', 'Entries') }} | ||
|
|
||
| ), | ||
|
|
||
| renamed as ( | ||
|
|
||
| select | ||
|
|
||
| EntryId as entry_id, | ||
| with_timezone(EntryTimestamp, 'UTC') as fault_occurred_at, | ||
| cast({{ adapter.quote('EntryTimestamp') }} as date) as fault_date, | ||
| trim(AdditionalComment) as fault_description, | ||
| case | ||
| when LogicallyDeleted = 'Y' then true | ||
| else false | ||
| end as logically_deleted | ||
|
|
||
| from source | ||
|
|
||
| ) | ||
|
|
||
| select * from renamed |
8 changes: 8 additions & 0 deletions
8
...lines/facility_ops/transform/models/staging/accelerator/base/base_opralogweb__entries.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| models: | ||
| - name: base_opralogweb__entries | ||
| description: > | ||
| Opralogweb "entries" table with basic cleaning. | ||
| columns: | ||
| - name: entry_id | ||
| tests: | ||
| - not_null |
21 changes: 21 additions & 0 deletions
21
...cility_ops/transform/models/staging/accelerator/base/base_opralogweb__logbook_chapter.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| with | ||
|
|
||
| source as ( | ||
|
|
||
| select * from {{ source('accelerator_opralogweb', 'LogBookChapter') }} | ||
|
|
||
| ), | ||
|
|
||
| renamed as ( | ||
|
|
||
| select | ||
|
|
||
| LogBookChapterNo as logbook_chapter_no | ||
|
|
||
| from | ||
|
|
||
| source | ||
|
|
||
| ) | ||
|
|
||
| select * from renamed |
7 changes: 7 additions & 0 deletions
7
...cility_ops/transform/models/staging/accelerator/base/base_opralogweb__logbook_chapter.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| models: | ||
| - name: base_opralogweb__logbook_chapter | ||
| description: Opralogweb logbook_chapter table with basic cleaning | ||
| columns: | ||
| - name: logbook_chapter_no | ||
| tests: | ||
| - not_null |
21 changes: 21 additions & 0 deletions
21
...ines/facility_ops/transform/models/staging/accelerator/base/base_opralogweb__logbooks.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| with | ||
|
|
||
| source as ( | ||
|
|
||
| select * from {{ source('accelerator_opralogweb', 'Logbooks') }} | ||
|
|
||
| ), | ||
|
|
||
| renamed as ( | ||
|
|
||
| select | ||
|
|
||
| LogbookId as logbook_id, | ||
| LogbookName as logbook_name | ||
|
|
||
| from | ||
|
|
||
| source | ||
| ) | ||
|
|
||
| select * from renamed |
7 changes: 7 additions & 0 deletions
7
...ines/facility_ops/transform/models/staging/accelerator/base/base_opralogweb__logbooks.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| models: | ||
| - name: base_opralogweb__logbooks | ||
| description: Opralogweb logbooks table with basic cleaning | ||
| columns: | ||
| - name: logbook_id | ||
| tests: | ||
| - not_null |
22 changes: 22 additions & 0 deletions
22
...ity_ops/transform/models/staging/accelerator/base/base_opralogweb__more_entry_columns.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| with | ||
|
|
||
| source as ( | ||
| select * from {{ source('accelerator_opralogweb', 'MoreEntryColumns') }} | ||
| ), | ||
|
|
||
| renamed as ( | ||
|
|
||
| select | ||
|
|
||
| EntryId as entry_id, | ||
| {{ normalize_whitespace('ColData') }} as string_data, | ||
| NumberValue as number_data, | ||
| AdditionalColumnId as additional_column_id | ||
|
|
||
| from | ||
|
|
||
| source | ||
|
|
||
| ) | ||
|
|
||
| select * from renamed |
7 changes: 7 additions & 0 deletions
7
...ity_ops/transform/models/staging/accelerator/base/base_opralogweb__more_entry_columns.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| models: | ||
| - name: base_opralogweb__more_entry_columns | ||
| description: Opralogweb more_entry_columns table with basic cleaning | ||
| columns: | ||
| - name: entry_id | ||
| tests: | ||
| - not_null |
97 changes: 97 additions & 0 deletions
97
...ility_ops/transform/models/staging/accelerator/stg_opralogweb__mcr_equipment_downtime.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| {%- set OPRALOG_EPOCH = dbt.string_literal("2017-04-25") -%} | ||
| {%- set MCR_LOGBOOK = dbt.string_literal("MCR Running Log") -%} | ||
|
|
||
| with | ||
|
|
||
| staging_entries as ( select * from {{ ref('base_opralogweb__entries') }} ), | ||
|
|
||
| staging_chapter_entry as ( select * from {{ ref('base_opralogweb__chapter_entry') }} ), | ||
|
|
||
| staging_logbook_chapter as ( select * from {{ ref('base_opralogweb__logbook_chapter') }} ), | ||
|
|
||
| staging_logbooks as ( select * from {{ ref('base_opralogweb__logbooks') }} ), | ||
|
|
||
| staging_more_entry_columns as ( select * from {{ ref('base_opralogweb__more_entry_columns') }} ), | ||
|
|
||
| staging_additional_columns as ( select * from {{ ref('base_opralogweb__additional_columns') }} ), | ||
|
|
||
| denormalized as ( | ||
| select | ||
|
|
||
| staging_entries.entry_id, | ||
| staging_entries.fault_occurred_at, | ||
| staging_entries.fault_date, | ||
| staging_additional_columns.column_title, | ||
| staging_more_entry_columns.string_data, | ||
| staging_more_entry_columns.number_data, | ||
| staging_entries.fault_description | ||
|
|
||
| from | ||
| staging_entries | ||
| join staging_chapter_entry on staging_chapter_entry.entry_id = staging_entries.entry_id | ||
| join staging_logbook_chapter on staging_logbook_chapter.logbook_chapter_no = staging_chapter_entry.logbook_chapter_no | ||
| join staging_logbooks on staging_logbooks.logbook_id = staging_chapter_entry.logbook_id | ||
| left outer join staging_more_entry_columns on staging_more_entry_columns.entry_id = staging_entries.entry_id | ||
| left outer join staging_additional_columns on staging_additional_columns.additional_column_id = staging_more_entry_columns.additional_column_id | ||
|
|
||
| where | ||
|
|
||
| staging_entries.logically_deleted = false | ||
| and staging_entries.fault_date >= from_iso8601_date({{ OPRALOG_EPOCH }}) | ||
| and staging_logbooks.logbook_name = {{ MCR_LOGBOOK }} | ||
| and staging_chapter_entry.logbook_id = staging_chapter_entry.principal_logbook | ||
| and staging_additional_columns.column_title in ('Equipment', 'Group', 'Lost Time', 'Group Leader comments') | ||
| and ( | ||
| staging_more_entry_columns.string_data is not null | ||
| or staging_more_entry_columns.number_data is not null | ||
| ) | ||
| ), | ||
|
|
||
| mcr_equipment_downtime as ( | ||
| select | ||
| * | ||
| from | ||
| ( | ||
| select | ||
|
|
||
| min( | ||
| case | ||
| column_title | ||
| when 'Equipment' then string_data | ||
| end | ||
| ) as equipment, | ||
| min( | ||
| case | ||
| column_title | ||
| when 'Lost Time' then number_data | ||
| end | ||
| ) as downtime_mins, | ||
| fault_date, | ||
| fault_occurred_at, | ||
| min( | ||
| case | ||
| column_title | ||
| when 'Group' then string_data | ||
| end | ||
| ) as {{ adapter.quote('group') }}, | ||
| fault_description, | ||
| min( | ||
| case | ||
| column_title | ||
| when 'Group Leader comments' then string_data | ||
| end | ||
| ) as managers_comments | ||
| from | ||
| denormalized | ||
| group by | ||
| fault_occurred_at, | ||
| fault_date, | ||
| fault_description | ||
| ) | ||
| where | ||
| equipment is not null | ||
| and downtime_mins is not null | ||
| and {{ adapter.quote('group') }} is not null | ||
| ) | ||
|
|
||
| select * from mcr_equipment_downtime |
41 changes: 41 additions & 0 deletions
41
...ility_ops/transform/models/staging/accelerator/stg_opralogweb__mcr_equipment_downtime.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| models: | ||
| - name: stg_opralogweb_mcr_equipment_downtime | ||
| description: > | ||
| Equipment downtime records for the MCR assembled from the relational | ||
| database of the web-based Opralog application. Entries before cycle 17/01 | ||
| are discarded as Opralog was in testing mode before this. | ||
|
|
||
| unit_tests: | ||
| - name: test_stg_opralogweb__mcr_equipment_downtime | ||
| description: "Check null & before epoch entries are discarded" | ||
| model: stg_opralogweb__mcr_equipment_downtime | ||
| given: | ||
| - input: ref('base_opralogweb__entries') | ||
| format: sql | ||
| fixture: base_opralogweb__entries | ||
| - input: ref('base_opralogweb__chapter_entry') | ||
| format: sql | ||
| fixture: base_opralogweb__chapter_entry | ||
| - input: ref('base_opralogweb__logbook_chapter') | ||
| format: sql | ||
| fixture: base_opralogweb__logbook_chapter | ||
| - input: ref('base_opralogweb__logbooks') | ||
| format: sql | ||
| fixture: base_opralogweb__logbooks | ||
| - input: ref('base_opralogweb__more_entry_columns') | ||
| format: sql | ||
| fixture: base_opralogweb__more_entry_columns | ||
| - input: ref('base_opralogweb__additional_columns') | ||
| format: sql | ||
| fixture: base_opralogweb__additional_columns | ||
| expect: | ||
| rows: | ||
| - { | ||
| equipment: "Equipment 101", | ||
| downtime_mins: 5.3, | ||
| fault_date: "2024-01-01", | ||
| fault_occurred_at: "2024-01-01 00:00:01 UTC", | ||
| group: "Group 101", | ||
| fault_description: "Comment 101", | ||
| managers_comments: null, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.