-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'current' into update-whitespace
- Loading branch information
Showing
3 changed files
with
28 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -69,7 +69,8 @@ check_valid_emails as ( | |
customers.customer_id, | ||
customers.first_name, | ||
customers.last_name, | ||
coalesce (regexp_like( | ||
customers.email, | ||
coalesce (regexp_like( | ||
customers.email, '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$' | ||
) | ||
= true | ||
|
@@ -97,20 +98,20 @@ unit_tests: | |
given: | ||
- input: ref('stg_customers') | ||
rows: | ||
- {customer_id: 1, email: [email protected], email_top_level_domain: example.com} | ||
- {customer_id: 2, email: [email protected], email_top_level_domain: unknown.com} | ||
- {customer_id: 3, email: badgmail.com, email_top_level_domain: gmail.com} | ||
- {customer_id: 4, email: missingdot@gmailcom, email_top_level_domain: gmail.com} | ||
- {email: [email protected], email_top_level_domain: example.com} | ||
- {email: [email protected], email_top_level_domain: unknown.com} | ||
- {email: badgmail.com, email_top_level_domain: gmail.com} | ||
- {email: missingdot@gmailcom, email_top_level_domain: gmail.com} | ||
- input: ref('top_level_email_domains') | ||
rows: | ||
- {tld: example.com} | ||
- {tld: gmail.com} | ||
expect: | ||
rows: | ||
- {customer_id: 1, is_valid_email_address: true} | ||
- {customer_id: 2, is_valid_email_address: false} | ||
- {customer_id: 3, is_valid_email_address: false} | ||
- {customer_id: 4, is_valid_email_address: false} | ||
- {email: [email protected], is_valid_email_address: true} | ||
- {email: [email protected], is_valid_email_address: false} | ||
- {email: badgmail.com, is_valid_email_address: false} | ||
- {email: missingdot@gmailcom, is_valid_email_address: false} | ||
|
||
``` | ||
</file> | ||
|
@@ -166,10 +167,10 @@ dbt test --select test_is_valid_email_address | |
|
||
actual differs from expected: | ||
|
||
@@ ,customer_id,is_valid_email_address | ||
→ ,1 ,True→False | ||
,2 ,False | ||
...,... ,... | ||
@@ ,email ,is_valid_email_address | ||
→ ,[email protected],True→False | ||
,[email protected],False | ||
...,... ,... | ||
|
||
|
||
16:03:51 | ||
|
@@ -179,7 +180,7 @@ actual differs from expected: | |
|
||
``` | ||
|
||
The clever regex statement wasn’t as clever as initially thought, as the model incorrectly flagged `[email protected]` (customer 1's email) as an invalid email address. | ||
The clever regex statement wasn’t as clever as initially thought, as the model incorrectly flagged `[email protected]` as an invalid email address. | ||
|
||
Updating the regex logic to `'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$'` (those pesky escape characters) and rerunning the unit test solves the problem: | ||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -162,20 +162,20 @@ unit_tests: | |
given: # the mock data for your inputs | ||
- input: ref('stg_customers') | ||
rows: | ||
- {customer_id: 1, email: [email protected], email_top_level_domain: example.com} | ||
- {customer_id: 2, email: [email protected], email_top_level_domain: unknown.com} | ||
- {customer_id: 3, email: badgmail.com, email_top_level_domain: gmail.com} | ||
- {customer_id: 4, email: missingdot@gmailcom, email_top_level_domain: gmail.com} | ||
- {email: [email protected], email_top_level_domain: example.com} | ||
- {email: [email protected], email_top_level_domain: unknown.com} | ||
- {email: badgmail.com, email_top_level_domain: gmail.com} | ||
- {email: missingdot@gmailcom, email_top_level_domain: gmail.com} | ||
- input: ref('top_level_email_domains') | ||
rows: | ||
- {tld: example.com} | ||
- {tld: gmail.com} | ||
expect: # the expected output given the inputs above | ||
rows: | ||
- {customer_id: 1, is_valid_email_address: true} | ||
- {customer_id: 2, is_valid_email_address: false} | ||
- {customer_id: 3, is_valid_email_address: false} | ||
- {customer_id: 4, is_valid_email_address: false} | ||
- {email: [email protected], is_valid_email_address: true} | ||
- {email: [email protected], is_valid_email_address: false} | ||
- {email: badgmail.com, is_valid_email_address: false} | ||
- {email: missingdot@gmailcom, is_valid_email_address: false} | ||
``` | ||
|
||
|
@@ -187,10 +187,10 @@ unit_tests: | |
given: # the mock data for your inputs | ||
- input: ref('stg_customers') | ||
rows: | ||
- {customer_id: 1, email: [email protected], email_top_level_domain: example.com} | ||
- {customer_id: 2, email: [email protected], email_top_level_domain: unknown.com} | ||
- {customer_id: 3, email: badgmail.com, email_top_level_domain: gmail.com} | ||
- {customer_id: 4, email: missingdot@gmailcom, email_top_level_domain: gmail.com} | ||
- {email: [email protected], email_top_level_domain: example.com} | ||
- {email: [email protected], email_top_level_domain: unknown.com} | ||
- {email: badgmail.com, email_top_level_domain: gmail.com} | ||
- {email: missingdot@gmailcom, email_top_level_domain: gmail.com} | ||
- input: ref('top_level_email_domains') | ||
format: csv | ||
rows: | | ||
|