创建视图语句:
CREATE OR REPLACE VIEW bdp_report_2593
AS
SELECT a.id, a.account_id, a.doc_id, a.pub_code, a.pub_type, a.pub_time, s1.name AS subject1, s2.name AS subject2,
s3.name AS subject3, s4.name AS subject4, s5.name AS subject5, s6.name AS subject6, a.subject_keyword,
a1.name AS aspect1, a2.name AS aspect2, a3.name AS aspect3, a4.name AS aspect4, a5.name AS aspect5, a6.name AS aspect6,
a.aspect_keyword, a.subject_sentiment_type_id as sentiment, a.subject_sentiment_keyword as sentiment_keyword, a.sentiment_type_id as sentiment_c,
a.unit_content, a.bi_status_id as bi_status, a.bi_attr_id as bi_attr, a.process_start_time, a.process_end_time,
a.reply_cnt, a.view_cnt, a.like_cnt, a.forward_cnt, a.dislike_cnt, a.collect_cnt, a.play_cnt, a.haha_cnt, a.love_cnt, a.wow_cnt,
a.angry_cnt, a.sad_cnt, a.care_cnt, a.coin_cnt, a.danmaku_cnt, a.pv, a.keyword, a.keyword_frequency, a.media_id, a.media_type_id, a.dedup_label, a.doc_type, a.author_tag, a.flag_qc, a.flag_reject
FROM fact_2593 a
LEFT JOIN dim_subject1_e23f99097f2d477392d3fde279cec0f3 s1 ON a.subject1_id = s1.subject1_id
LEFT JOIN dim_subject2_e23f99097f2d477392d3fde279cec0f3 s2 ON a.subject2_id = s2.subject2_id
LEFT JOIN dim_subject3_e23f99097f2d477392d3fde279cec0f3 s3 ON a.subject3_id = s3.subject3_id
LEFT JOIN dim_subject4_e23f99097f2d477392d3fde279cec0f3 s4 ON a.subject4_id = s4.subject4_id
LEFT JOIN dim_subject5_e23f99097f2d477392d3fde279cec0f3 s5 ON a.subject5_id = s5.subject5_id
LEFT JOIN dim_subject6_e23f99097f2d477392d3fde279cec0f3 s6 ON a.subject6_id = s6.subject6_id
LEFT JOIN (select * from dim_aspect_eb59ed0d2dd94914ba05988155a2541d) a1 ON a.aspect1_id = a1.aspect_id AND a1.level = 1
LEFT JOIN (select * from dim_aspect_eb59ed0d2dd94914ba05988155a2541d) a2 ON a.aspect2_id = a2.aspect_id AND a2.level = 2
LEFT JOIN (select * from dim_aspect_eb59ed0d2dd94914ba05988155a2541d) a3 ON a.aspect3_id = a3.aspect_id AND a3.level = 3
LEFT JOIN (select * from dim_aspect_eb59ed0d2dd94914ba05988155a2541d) a4 ON a.aspect4_id = a4.aspect_id AND a4.level = 4
LEFT JOIN (select * from dim_aspect_eb59ed0d2dd94914ba05988155a2541d) a5 ON a.aspect5_id = a5.aspect_id AND a5.level = 5
LEFT JOIN (select * from dim_aspect_eb59ed0d2dd94914ba05988155a2541d) a6 ON a.aspect6_id = a6.aspect_id AND a6.level = 6