notebook/996/动态表/建表.sql
2025-07-11 15:32:31 +08:00

53 lines
1.1 KiB
PL/PgSQL

BEGIN;
/*
DROP TABLE ods.yinzhou_dynamic_demo;
*/
-- Type: TABLE ; Name: yinzhou_dynamic_demo; Owner: sdk_statis_test_developer
SET LOCAL SEARCH_PATH TO 'public';
CREATE DYNAMIC TABLE ods.yinzhou_dynamic_demo (
ds,
id,
name,
device_cut,
user_cut
)with (
orientation = 'column',
storage_format = 'orc',
binlog_level = 'replica',
binlog_ttl = '864000',
bitmap_columns = 'ds,name',
dictionary_encoding_columns = 'ds:auto,name:auto',
distribution_key = 'ds,id',
table_group = 'sdk_statis_test_tg_default',
table_storage_mode = 'hot',
time_to_live_in_seconds = '3153600000',
auto_refresh_enable='true',
full_auto_refresh_interval='1 hour',
full_auto_refresh_schd_start_time='immediate',
full_guc_hg_computing_resource='local',
refresh_mode='full'
) AS SELECT
t1.ds,t2.ID,
t2.NAME,
UNIQ ( device_id ) device_cut,
UNIQ ( user_id ) user_cut
FROM
"ods_track_log" t1
INNER JOIN "public"."gm_apply" FOR SYSTEM_TIME AS OF PROCTIME() t2
ON t1.appid = t2."id"
GROUP BY
t1.ds,
t2.ID,
t2.NAME;
COMMENT ON TABLE ods.yinzhou_dynamic_demo IS NULL;
ALTER TABLE ods.yinzhou_dynamic_demo OWNER TO sdk_statis_test_developer;
END;