-- DROP TABLE micro_operation_content_pool_day_temp;
CREATE TABLE IF NOT EXISTS micro_operation_content_pool_day_temp
(
channel string COMMENT '渠道'
,content_id BIGINT COMMENT '内容id'
,createTime BIGINT COMMENT '插入时间'
,content_pool_id BIGINT COMMENT '数据池id,如首页推荐池,精选频道推荐池'
,data_source STRING COMMENT '数据来源,如点将台场景666'
,data_version STRING COMMENT '数据版本'
)
PARTITIONED BY
(
ds STRING
)
LIFECYCLE 3
;
INSERT OVERWRITE TABLE micro_operation_content_pool_day_temp PARTITION(ds='${bizdate}')
SELECT "data_pool_diff" as channel
,content_id
,unix_timestamp(getdate()) as createTime
,content_pool_id
,data_source
,data_version
FROM (
SELECT content_id
,content_pool_id
,data_source
,data_version
,MAX(data_version) OVER (PARTITION BY content_pool_id,data_source) AS max_data_version
FROM (
SELECT id
,bi_udf:bi_get_json_object(features,'$.refer_id') AS content_id
,bi_udf:bi_get_json_object(features, '$.scene_id') AS content_pool_id
,bi_udf:bi_get_json_object(features,'$.data_source') AS data_source
,bi_udf:bi_get_json_object(features, '$.data_version') AS data_version
,bi_udf:bi_get_json_object(features,'$.type') AS data_source_type
FROM tbods.s_macross_feed
WHERE ds = '${bizdate}'
AND biz_type = 503
AND status = 0
) a
WHERE a.data_source_type = 1
AND a.data_source IS NOT NULL
AND a.data_version IS NOT NULL
AND a.content_id IS NOT NULL
) b
WHERE data_version = max_data_version
;
-- SELECT temp.content_id from
-- micro_operation_content_pool_day_temp temp LEFT OUTER JOIN tbods.s_motor_content s
-- on temp.content_id = s.id
-- WHERE temp.content_id != NULL
-- and s.id = NULL
-- and temp.ds="${bizdate}"
-- and s.ds="${bizdate}";
CREATE TABLE IF NOT EXISTS data_pool_diff_day
(
channel string COMMENT '渠道'
,content_id BIGINT COMMENT '内容id'
,createTime BIGINT COMMENT '插入时间'
)
PARTITIONED BY
(
ds STRING
)
LIFECYCLE 3;
INSERT OVERWRITE TABLE data_pool_diff_day PARTITION(ds='${bizdate}')
SELECT
channel
,content_id
,createTime
FROM (
SELECT a.content_id as content_id,b.id as id from
(SELECT * from micro_operation_content_pool_day_temp WHERE ds=="${bizdate}") a
LEFT OUTER JOIN
(select * from tbods.s_motor_content WHERE ds=="${bizdate}") b
on a.content_id = b.id
) A
WHERE A.content_id is not null and A.id is NULL;
SELECT * from data_pool_diff_day WHERE ds="${bizdate}";
CREATE TABLE IF NOT EXISTS sxpt_scene_content_check_complete (
create_time DATETIME
)
PARTITIONED BY (
ds STRING
);
Alter table sxpt_scene_content_check_complete drop if exists partition(ds='${bizdate}');
INSERT overwrite TABLE sxpt_scene_content_check_complete partition (ds='${bizdate}') VALUES (getdate());
SELECT * from micro_data.sxpt_scene_content_check_complete where ds='20180407';
CREATE TABLE IF NOT EXISTS garbage_relation_add_daily (
user_id bigint,
account_id bigint,
tag_list string
)
PARTITIONED BY (
ds STRING
);
Alter table garbage_relation_add_daily drop if exists partition(ds='${bizdate}');
INSERT overwrite TABLE garbage_relation_add_daily partition (ds='${bizdate}')
select *
from
micro_data.relation_clean_result t
where
(t.user_id % 180) = (datediff(to_date('${bizdate}', 'yyyymmdd'), '2017-08-15 00:00:00','dd') % 180)
and instr(t.tag_list, ',') != 0;
SELECT
A.content_id
,A.pic_url
,A.result_pic_url
FROM (
SELECT a.content_id as content_id,
b.content_id as id,
b.pic_url as pic_url,
b.result_pic_url as result_pic_url
FROM
(
SELECT content_id FROM beehive.sxpt_scene_9207 WHERE ds="20180418"
UNION SELECT content_id FROM beehive.sxpt_scene_8835 WHERE ds="20180418"
UNION SELECT content_id FROM beehive.sxpt_scene_8984 WHERE ds="20180419"
UNION SELECT content_id FROM beehive.sxpt_scene_8718 WHERE ds="20180419"
UNION SELECT content_id FROM beehive.sxpt_scene_8994 WHERE ds="20180419"
UNION SELECT content_id FROM beehive.sxpt_scene_9004 WHERE ds="20180419"
UNION SELECT content_id FROM beehive.sxpt_scene_9229 WHERE ds="20180419"
UNION SELECT content_id FROM beehive.sxpt_scene_9237 WHERE ds="20180419"
) a
LEFT OUTER JOIN
(select * from luban.pixel_need_1x1_cover_pic_result WHERE ds="20180418") b
on a.content_id = b.content_id
) A
WHERE A.content_id is not null and A.id is NOT NULL
drop table if exists relation_clean_final;
create table if not exists relation_clean_final(
user_id bigint,
account_id bigint,
tag_list String
);
insert overwrite table relation_clean_final
select
t1.src_link_id,
t1.dest_link_id,
t1.tag_list
from
secdm.mdl_mz_weitao_eyi_links_fdt t1
join
(
select
user_id
from
relation_clean_num
where
num > 100 ) t2
on t1.ds= 20170702 and t1.src_link_id = t2.user_id;
CREATE TABLE IF NOT EXISTS garbage_relation_add_daily (
user_id bigint,
account_id bigint,
tag_list string
)
PARTITIONED BY (
ds STRING
);
INSERT INTO TABLE garbage_relation_add_daily partition (ds='${bizdate}')
select *
from relation_clean_final t
where t.account_id % 180 = ('${bizdate}' - 20170815) % 1