Skip to content

Commit

Permalink
more mappingdict adds
Browse files Browse the repository at this point in the history
more mappingdict adds
  • Loading branch information
rlsalcido24 committed May 17, 2024
1 parent 544bc0d commit d2564c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion helper/convert_to_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def finalcountdown(finaldf, contentstring, targetstring):
for sourcesting, args in zip(finaldf["funcstring"], finaldf["args"]):
if targetstring == "CASE WHEN lower(#arg0) IN ('year', 'years','y', 'yr', 'yrs') THEN date_trunc('year', #arg1::timestamp)::timestamp WHEN lower(#arg0) IN ('month', 'months', 'mon', 'mons') THEN date_trunc('month', #arg1::timestamp)::timestamp WHEN lower(#arg0) IN ('week', 'weeks', 'w') THEN date_trunc('week', #arg1::timestamp)::timestamp WHEN lower(#arg0) IN ('day', 'days', 'd') THEN date_trunc('day', #arg1::timestamp)::timestamp ELSE NULL END":
tiempounit = args[0]
mappingdict = {"year": "date_trunc('year', #arg1::timestamp)", "years": "date_trunc('year', #arg1::timestamp)", "y": "date_trunc('year', #arg1::timestamp)", "yr": "date_trunc('year', #arg1::timestamp)", "yrs": "date_trunc('year', #arg1::timestamp)", "month": "date_trunc('month', #arg1::timestamp)", "months": "date_trunc('month', #arg1::timestamp)", "mon": "date_trunc('month', #arg1::timestamp)", "mons": "date_trunc('month', #arg1::timestamp)", "week": "date_trunc('week', #arg1::timestamp)", "weeks": "date_trunc('week', #arg1::timestamp)", "w": "date_trunc('week', #arg1::timestamp)", "day": "date_trunc('day', #arg1::timestamp)", "days": "date_trunc('day', #arg1::timestamp)", "d": "date_trunc('day', #arg1::timestamp)"}
mappingdict = {"year": "date_trunc('year', #arg1::timestamp)", "years": "date_trunc('year', #arg1::timestamp)", "y": "date_trunc('year', #arg1::timestamp)", "yr": "date_trunc('year', #arg1::timestamp)", "yrs": "date_trunc('year', #arg1::timestamp)", "month": "date_trunc('month', #arg1::timestamp)", "months": "date_trunc('month', #arg1::timestamp)", "mon": "date_trunc('month', #arg1::timestamp)", "mons": "date_trunc('month', #arg1::timestamp)", "week": "date_trunc('week', #arg1::timestamp)", "weeks": "date_trunc('week', #arg1::timestamp)", "w": "date_trunc('week', #arg1::timestamp)", "day": "date_trunc('day', #arg1::timestamp)", "days": "date_trunc('day', #arg1::timestamp)", "d": "date_trunc('day', #arg1::timestamp)", "hour": "date_trunc('hour', #arg1::timestamp)", "hours": "date_trunc('hour', #arg1::timestamp)", "hr": "date_trunc('hour', #arg1::timestamp)", "hrs": "date_trunc('hour', #arg1::timestamp)", "h": "date_trunc('hour', #arg1::timestamp)", "minute": "date_trunc('minute', #arg1::timestamp)", "minutes": "date_trunc('minute', #arg1::timestamp)", "mins": "date_trunc('minute', #arg1::timestamp)", "min": "date_trunc('minute', #arg1::timestamp)", "m": "date_trunc('minute', #arg1::timestamp)", "second": "date_trunc('second', #arg1::timestamp)", "seconds": "date_trunc('second', #arg1::timestamp)", "secs": "date_trunc('second', #arg1::timestamp)", "sec": "date_trunc('second', #arg1::timestamp)", "s": "date_trunc('second', #arg1::timestamp)" }
tiempunitnosq = tiempounit.replace("'", "")
tiempunitnodq = tiempunitnosq.replace('"','')
cwval = mappingdict[tiempunitnodq]
Expand Down
2 changes: 2 additions & 0 deletions models/redshift/customerrs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ select
c_phone,
(to_char(date_trunc('month', getdate()), 'YYYY-MM')) as month,
datediff(days, getdate(), getdate()) as days_since_oldest_unpaid_due_date,
datediff(hours, getdate(), getdate()) as days_since_oldest_unpaid_due_date
date_trunc('months', getdate()),
date_trunc('hours', getdate()),
dateadd('day', -1, getdate()),
case when 'organictest' ~ 'organic|email' then 'match' else 'no match' end as regexmatch,
case when 'organictest' !~ 'organic|email' then 'antimatch' else 'antino match' end as antiregexmatch
Expand Down

0 comments on commit d2564c8

Please sign in to comment.