notebook/flinksql/sqlcopy/sls2holo_sdk_login_log.sql
2025-04-01 11:41:15 +08:00

81 lines
2.1 KiB
SQL

--********************************************************************--
-- Author: zhougongping@1253758386586182.onaliyun.com
-- Created Time: 2023-04-11 15:17:43
-- Description: Write your description here
--********************************************************************--
CREATE TEMPORARY TABLE sls_com_login_log (
app_ver VARCHAR
,appid VARCHAR
,channel VARCHAR
,device_height INT
,device_id VARCHAR
,device_lang VARCHAR
,device_model VARCHAR
,device_os VARCHAR
,device_type VARCHAR
,device_width INT
,event_time INT
,ip VARCHAR
,net_type VARCHAR
,user_id INT
) WITH (
'connector' = 'sls',
'endPoint' = 'cn-hangzhou-intranet.log.aliyuncs.com',
'accessId' = '${secret_values.996engine_ak}',
'accessKey' = '${secret_values.996engine_sk}',
-- 'startTime' = '2023-04-11 00:00:00',
'project' = 'game-sdk',
'logStore' = 'com-login',
'consumerGroup' = 'sls2holo_com_login'
);
CREATE TEMPORARY TABLE ods_user_profile_login (
app_ver VARCHAR
,appid VARCHAR
,channel VARCHAR
,device_id VARCHAR
,device_lang VARCHAR
,device_model VARCHAR
,device_os VARCHAR
,device_type VARCHAR
,device_height INT
,device_width INT
,ip VARCHAR
,net_type VARCHAR
,user_id INT
,event_time TIMESTAMP
,ds VARCHAR
,PRIMARY KEY (appid, device_id, ds) NOT ENFORCED
) WITH (
'connector' = 'hologres',
'endpoint' = 'hgprecn-cn-n8m2xw5ez001-cn-hangzhou-vpc.hologres.aliyuncs.com:80',
'username' = '${secret_values.996engine_ak}',
'password' = '${secret_values.996engine_sk}',
'dbname' = 'dhsf_engine',
'tablename' = 'ods_user_profile_login',
'ignoredelete' = 'true',
'mutatetype' = 'insertorignore'
);
INSERT INTO
ods_user_profile_login
SELECT
app_ver
,appid
,channel
,device_id
,device_lang
,device_model
,device_os
,device_type
,device_height
,device_width
,ip
,net_type
,user_id
,TO_TIMESTAMP_TZ(FROM_UNIXTIME(event_time, 'yyyy-MM-dd HH:mm:ss'), 'Asia/Shanghai') AS event_time
,FROM_UNIXTIME(event_time, 'yyyyMMdd') AS ds
FROM
sls_com_login_log
;