You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the past I had raised an issue with converting "Volatile" property and "WITH DATA" clause while converting from Teradata to snowflake/databricks. Reference: #1205
There was also a PR created for this fix (#1219)
However, when i update the latest package there seems to be an error and the with data clause is also preserved. Example below
sql = """
create volatile table temp
as(
select
current_date as curr_cal_dt,
add_months(cal_dt, -1) as rptd_month_strt_dt,
cal_dt-extract(day from cal_dt) as rptd_month_end_dt,
add_months(cal_dt,-12) as yr1_strt_dt,
cal_dt-extract(day from cal_dt) as yr1_end_dt,
add_months(cal_dt,-24) as yr2_strt_dt,
from
dim_cal_day
where cal_dt between add_months(current_date,-1) and current_date
)with data primary index (yr2_strt_dt,yr1_end_dt) on commit preserve rows;
"""
try:
new_query = sqlglot.transpile(sql, read='teradata', write='databricks', pretty=True)[0]
print(new_query)
except sqlglot.errors.ParseError as error:
print(traceback.format_exc())
print(error.errors)
Output:
Unsupported property volatileproperty
CREATE TABLE temp AS
(
SELECT
CURRENT_DATE AS curr_cal_dt,
ADD_MONTHS(cal_dt, -1) AS rptd_month_strt_dt,
cal_dt - EXTRACT(day FROM cal_dt) AS rptd_month_end_dt,
ADD_MONTHS(cal_dt, -12) AS yr1_strt_dt,
cal_dt - EXTRACT(day FROM cal_dt) AS yr1_end_dt,
ADD_MONTHS(cal_dt, -24) AS yr2_strt_dt
FROM dim_cal_day
WHERE
cal_dt BETWEEN ADD_MONTHS(CURRENT_DATE, -1) AND CURRENT_DATE
) WITH DATA
ON COMMIT PRESERVE ROWS PRIMARY INDEX (yr2_strt_dt, yr1_end_dt)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In the past I had raised an issue with converting "Volatile" property and "WITH DATA" clause while converting from Teradata to snowflake/databricks. Reference: #1205
There was also a PR created for this fix (#1219)
However, when i update the latest package there seems to be an error and the with data clause is also preserved. Example below
Output:
Can someone help me get the fix back in?
Beta Was this translation helpful? Give feedback.
All reactions