Add EXTERNAL SQL scripts

This commit is contained in:
2026-04-20 14:55:25 +08:00
parent c05ba7ec7e
commit b4979eed82
344 changed files with 61619 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
-- Databricks notebook source
-- 依赖事实表 tmp.tmp_ims_tf_fact_sales 所以一定要放后面。
--Fact数据动态计算时间维度
insert overwrite table dws.dws_ims_td_date
select distinct
YM,
left(cast(YM as string),4) as YEAR,
right(cast(YM as string),2) as MONTH,
concat(
'Q',quarter(
date(
concat(
left(cast(YM as string),4),'-',right(cast(YM as string),2),'-01'
)))) as QUARTER,
concat(
left(cast(YM as string),4),'Q',quarter(
date(
concat(
left(cast(YM as string),4),'-',right(cast(YM as string),2),'-01'
)))) as YQ,
case when YM=(select max(YM) from tmp.tmp_ims_tf_fact_sales) then 'R' else right(cast(YM as string),2) end as DATE_FLAG,
case when YM%100>6 then concat(left(cast(YM as string),4),'H2') else concat(left(cast(YM as string),4),'H1') end as HALF_YEAR,
from_utc_timestamp(current_timestamp(),'UTC+8'),
from_utc_timestamp(current_timestamp(),'UTC+8')
from tmp.tmp_ims_tf_fact_sales
where YM > (select max(YM)-900 from tmp.tmp_ims_tf_fact_sales)
order by YM desc
;