Skip to content

Commit

Permalink
mappingdict microsecond
Browse files Browse the repository at this point in the history
mappingdict microsecond
  • Loading branch information
rlsalcido24 committed May 21, 2024
1 parent b427fa4 commit 964de90
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions helper/convert_to_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def splitargstuple(finalparsedstrings, goldenargs, flag, sourcepattern):
platinumreplace = '"xmlgetplaceholder"'
if noisylogs == 'true':
print(f'the val of platniumreplace is {platinumreplace}')
platinumreplace = platinumreplace.replace("\n", "")
platinumreplace = platinumreplace.replace("\n", "")
platinumreplace = platinumreplace.replace(" ", "")
platinumtuple = eval(platinumreplace)
llavesplatinum = platinum["uniquekey"]
secondsilverdict = {"args": platinumtuple, "uniquekey": llavesplatinum}
Expand All @@ -290,15 +291,15 @@ 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)", "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)" }
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)", "millisecond": "date_trunc('millisecond', #arg1::timestamp)", "milliseconds": "date_trunc('millisecond', #arg1::timestamp)", "msec": "date_trunc('millisecond', #arg1::timestamp)", "msecs": "date_trunc('millisecond', #arg1::timestamp)", "ms": "date_trunc('millisecond', #arg1::timestamp)" }
tiempunitnosq = tiempounit.replace("'", "")
tiempunitnodq = tiempunitnosq.replace('"','')
cwval = mappingdict[tiempunitnodq]
lastarget = cwval.replace('#arg1', args[1])
updated_content = updated_content.replace(sourcesting, lastarget)
elif targetstring == "CASE WHEN lower( '#arg0') IN ('year', 'years','y', 'yr', 'yrs') THEN FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1) WHEN lower( '#arg0') IN ('month', 'months', 'mon', 'mons') THEN timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp) WHEN lower( '#arg0') IN ('week', 'weeks', 'w') THEN timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp) WHEN lower( '#arg0') IN ('day', 'days', 'd') THEN timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp) ELSE NULL END":
tiempounit = args[0]
mappingdict = {"year": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "years": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "y": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "yr": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "yrs": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "month": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "months": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "mon": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "mons": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "week": "timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp)", "weeks": "timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp)", "w": "timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp)", "day": "timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp)", "days": "timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp)", "d": "timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp)", "hour": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "hours": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "hr": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "hrs": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "h": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "minutes": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "minute": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "mins": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "min": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "m": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "seconds": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "second": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "secs": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "sec": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "s": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)"}
mappingdict = {"year": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "years": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "y": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "yr": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "yrs": "FLOOR(timestampdiff(YEAR, #arg1::timestamp, #arg2::timestamp) / 1)", "month": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "months": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "mon": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "mons": "timestampdiff(MONTH, #arg1::timestamp, #arg2::timestamp)", "week": "timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp)", "weeks": "timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp)", "w": "timestampdiff(WEEK, #arg1::timestamp, #arg2::timestamp)", "day": "timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp)", "days": "timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp)", "d": "timestampdiff(DAY, #arg1::timestamp, #arg2::timestamp)", "hour": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "hours": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "hr": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "hrs": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "h": "timestampdiff(hour, #arg1::timestamp, #arg2::timestamp)", "minutes": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "minute": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "mins": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "min": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "m": "timestampdiff(minute, #arg1::timestamp, #arg2::timestamp)", "seconds": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "second": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "secs": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "sec": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "s": "timestampdiff(second, #arg1::timestamp, #arg2::timestamp)", "milliseconds": "timestampdiff(millisecond, #arg1::timestamp, #arg2::timestamp)", "millisecond": "timestampdiff(millisecond, #arg1::timestamp, #arg2::timestamp)", "msecs": "timestampdiff(millisecond, #arg1::timestamp, #arg2::timestamp)", "msec": "timestampdiff(millisecond, #arg1::timestamp, #arg2::timestamp)", "ms": "timestampdiff(millisecond, #arg1::timestamp, #arg2::timestamp)" }
tiempunitnosq = tiempounit.replace("'", "")
tiempunitnodq = tiempunitnosq.replace('"','')
cwval = mappingdict[tiempunitnodq]
Expand Down

0 comments on commit 964de90

Please sign in to comment.