Skip to content

Commit

Permalink
updated standup file, explicitly cast types for audit_key
Browse files Browse the repository at this point in the history
  • Loading branch information
norton120 committed Aug 14, 2018
1 parent b9ac8d2 commit 4be8b48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions audits/AUDIT_FACT.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
---- RETURNS: dict of lists, each list containing the comma-deliniated values for each row

SELECT
audit_key,
-- snowflake needs this explicictly cast for some reason
audit_key::NUMBER AS audit_key,
database_key,
schema_key,
entity_key,
Expand Down Expand Up @@ -51,9 +52,9 @@
)

SELECT
audit_key,
gross_record_count,
gross_record_count - error_event_count AS validated_record_count,
audit_key::NUMBER AS audit_key,
gross_record_count::NUMBER AS gross_record_count,
gross_record_count::NUMBER - error_event_count::NUMBER AS validated_record_count,
CURRENT_TIMESTAMP() AS audit_completed_at,
{{date_key('CURRENT_DATE()')}} AS audit_date_key
FROM
Expand Down
7 changes: 3 additions & 4 deletions kdbt_standup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ CREATE OR REPLACE SEQUENCE quality_audit_pk_seq start = 100000

CREATE TABLE AUDIT (
audit_key INTEGER PRIMARY KEY DEFAULT quality_audit_pk_seq.nextval,
dbt_repo_release_version VARCHAR NOT NULL, -- not sure how to populate these within DBT context yet,
dbt_version VARCHAR NOT NULL, -- but good to have as placeholders.
app_version VARCHAR NOT NULL,
release VARCHAR NOT NULL,
dbt_version VARCHAR NOT NULL,
database_key VARCHAR NOT NULL,
schema_key VARCHAR NOT NULL,
entity_key VARCHAR NOT NULL,
Expand All @@ -31,8 +32,6 @@ CREATE TABLE AUDIT_FACT (
gross_record_count INTEGER,
validated_record_count INTEGER,
audit_completed_at TIMESTAMP_LTZ,

-- this should be fkey'd to the audit date view in the prod model
audit_date_key INTEGER

);
Expand Down
3 changes: 2 additions & 1 deletion screens/ERROR_EVENT_FACT.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ unioned_error_events AS (
---- create the final partial
SELECT
sequence.nextval AS error_event_key,
audit_key,
-- for some reason snowflake needs this explicitly cast
audit_key::NUMBER AS audit_key,
screen_name,
error_subject,
record_identifier,
Expand Down

0 comments on commit 4be8b48

Please sign in to comment.