Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bi-report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data
bi-report
Commits
846c3e27
Commit
846c3e27
authored
Aug 26, 2020
by
魏艺敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push codes
parent
d7b95cc8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
149 deletions
+148
-149
daily_operation.sql
pm/daily_operation/etl/daily_operation.sql
+148
-149
No files found.
pm/daily_operation/etl/daily_operation.sql
View file @
846c3e27
...
...
@@ -120,21 +120,21 @@ FROM
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -153,8 +153,8 @@ FROM
SELECT
device_id
,
concat_ws
(
'-'
,
substr
(
partition_date
,
1
,
4
),
substr
(
partition_date
,
5
,
2
),
substr
(
partition_date
,
7
,
2
))
as
partition_date
FROM
online
.
ml_device_day_active_status
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
t2
on
t1
.
device_id
=
t2
.
device_id
...
...
@@ -176,8 +176,8 @@ LEFT JOIN
(
select
device_id
,
use_duration
,
partition_date
,
open_times
from
online
.
ml_device_updates
where
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
b
JOIN
(
...
...
@@ -196,21 +196,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
...
...
@@ -264,8 +264,8 @@ LEFT JOIN
(
SELECT
page_name
,
cl_id
,
partition_date
,
cl_type
,
referrer
,
action
,
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
action
=
'page_view'
AND
((
page_name
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
,
'search_result_more'
,
'search_result_welfare'
,
'search_result_hospital'
,
'search_result_export'
,
'search_result_doctor'
,
'search_result_organization'
))
...
...
@@ -276,8 +276,8 @@ LEFT JOIN
UNION
ALL
SELECT
page_name
,
cl_id
,
partition_date
,
cl_type
,
referrer
,
'click_neirong'
as
action
,
'no'
as
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
page_name
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
and
(
action
=
'on_click_card'
and
params
[
'card_content_type'
]
in
(
'qa'
,
'diary'
,
'user_post'
,
'answer'
)
or
action
=
'post_detail_browse_card'
)
...
...
@@ -285,8 +285,8 @@ LEFT JOIN
UNION
ALL
SELECT
page_name
,
cl_id
,
partition_date
,
cl_type
,
referrer
,
'wel_second'
as
action
,
'no'
as
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
page_name
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
and
params
[
'referrer'
]
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
AND
((
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'more_recommendations'
)
...
...
@@ -297,8 +297,8 @@ LEFT JOIN
UNION
ALL
SELECT
page_name
,
cl_id
,
partition_date
,
cl_type
,
referrer
,
'neirong_second'
as
action
,
'no'
as
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
page_name
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
AND
params
[
'referrer'
]
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
--内容详情页-搜索首页-进行搜索
and
(
action
in
(
'on_click_navbar_search'
,
'do_search'
)
...
...
@@ -308,16 +308,16 @@ LEFT JOIN
UNION
ALL
SELECT
'service_privacy'
as
page_name
,
cl_id
,
partition_date
,
cl_type
,
'no'
as
referrer
,
'popup_view'
as
action
,
'no'
as
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
--隐私弹窗弹出事件
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--隐私弹窗弹出事件
and
action
=
'popup_view'
AND
params
[
'popup_name'
]
=
'service_privacy'
UNION
ALL
SELECT
'service_privacy'
as
page_name
,
cl_id
,
partition_date
,
cl_type
,
'no'
as
referrer
,
'popup_click'
as
action
,
'no'
as
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
--隐私弹窗弹出事件
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--隐私弹窗弹出事件
and
action
=
'on_click_button'
AND
params
[
'popup_name'
]
=
'service_privacy'
AND
params
[
'type'
]
=
'service_privacy'
...
...
@@ -343,21 +343,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -377,7 +377,7 @@ LEFT JOIN
(
-- 2.去掉疑似机构刷量的PV和UV
SELECT
device_id
FROM
ml
.
ml_d_ct_dv_devicespam_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
spam_pv
on
a
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
...
...
@@ -413,20 +413,20 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
IN
(
'1'
,
'2'
,
'4'
)
AND
first_channel_source_type
not
IN
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -441,7 +441,7 @@ LEFT JOIN
(
SELECT
partition_day
as
partition_date
,
device_id
as
cl_id
,
card_id
,
app_session_id
FROM
ml
.
mid_ml_c_et_pe_preciseexposure_dimen_d
--新仓库精准曝光
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
page_code
=
'home'
AND
is_exposure
=
'1'
AND
tab_code
=
'精选'
...
...
@@ -456,7 +456,7 @@ LEFT JOIN
(
-- 去掉疑似机构刷量的PV和UV
SELECT
distinct
device_id
FROM
ml
.
ml_d_ct_dv_devicespam_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
spam_pv
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
...
...
@@ -493,20 +493,20 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
WHERE
partition_date
>=
'${start_date}'
and
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
IN
(
'1'
,
'2'
,
'4'
)
AND
first_channel_source_type
not
IN
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -521,7 +521,7 @@ LEFT JOIN
(
SELECT
partition_day
as
partition_date
,
device_id
as
cl_id
,
card_id
,
app_session_id
FROM
ml
.
ml_c_et_ck_click_dimen_d
--新仓库点击表
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
action
=
'on_click_card'
AND
page_code
=
'home'
AND
tab_code
=
'精选'
...
...
@@ -535,7 +535,7 @@ LEFT JOIN
(
-- 去掉疑似机构刷量的PV和UV
SELECT
distinct
device_id
FROM
ml
.
ml_d_ct_dv_devicespam_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
spam_pv
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
...
...
@@ -565,11 +565,11 @@ LEFT JOIN
(
--新增帖子(用户发的)
SELECT
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
'tractate'
as
type
,
count
(
DISTINCT
id
)
as
num
FROM
online
.
tl_hdfs_api_tractate_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
is_online
=
'true'
AND
platform
=
'1'
--更美用户发的(去除hera后台,爬虫爬取的)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
),
'tractate'
UNION
ALL
...
...
@@ -579,11 +579,11 @@ LEFT JOIN
(
SELECT
user_id
,
id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
FROM
online
.
tl_hdfs_api_tractate_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
is_online
=
'true'
AND
platform
=
'7'
--打卡发帖
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
a
LEFT
JOIN
...
...
@@ -591,8 +591,8 @@ LEFT JOIN
SELECT
t
.
user_id
,
partition_date
,
if
(
size
(
t
.
device_list
)
>
0
,
device_list
[
0
],
''
)
device_id
FROM
online
.
ml_user_updates
t
WHERE
t
.
partition_date
>=
'${start_date}'
and
t
.
partition_date
<
'${end_date}'
WHERE
t
.
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
t
.
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
b
ON
a
.
user_id
=
b
.
user_id
AND
a
.
create_date
=
b
.
partition_date
...
...
@@ -602,8 +602,8 @@ LEFT JOIN
SELECT
partition_date
,
device_id
FROM
online
.
ml_device_day_active_status
--中kyc灰度的设备
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
)
AND
((
partition_date
<=
'20200511'
AND
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
1
)
=
'0'
)
or
(
partition_date
>=
'20200512'
AND
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
2
,
2
)
%
20
=
0
))
...
...
@@ -613,7 +613,6 @@ LEFT JOIN
WHERE
c
.
device_id
is
NULL
GROUP
BY
a
.
user_id
,
create_date
,
'tractate'
UNION
ALL
--新增日记本
SELECT
a
.
user_id
,
a
.
create_date
,
'diary'
as
type
,
count
(
DISTINCT
a
.
id
)
as
num
...
...
@@ -621,17 +620,17 @@ LEFT JOIN
(
SELECT
user_id
,
id
,
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
as
create_date
FROM
online
.
tl_hdfs_diary_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--and is_online = 'true'
--AND is_spam = 'false' --排除疑似广告
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
a
JOIN
(
--取非空日记
SELECT
diary_id
FROM
online
.
tl_hdfs_problem_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
is_spam
=
'false'
)
b
ON
a
.
id
=
b
.
diary_id
...
...
@@ -641,36 +640,36 @@ LEFT JOIN
--新增日记帖
SELECT
user_id
,
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
'topic'
as
type
,
count
(
DISTINCT
id
)
as
num
FROM
online
.
tl_hdfs_problem_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--and is_online = 'true'
AND
is_spam
=
'false'
--排除疑似广告
AND
diary_id
is
not
null
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
user_id
,
regexp_replace
(
substr
(
created_time
,
1
,
10
),
'-'
,
''
),
'topic'
UNION
ALL
--新增问题
SELECT
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
'question'
as
type
,
count
(
DISTINCT
id
)
as
num
FROM
online
.
tl_hdfs_question_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--and is_online = 'true'
AND
is_spam
=
'false'
--排除疑似广告
AND
platform
=
'99'
--更美用户发的(去除hera后台,爬虫爬取的,kyc自动回复的)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
),
'question'
UNION
ALL
--新增回答
SELECT
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
create_date
,
'answer'
as
type
,
count
(
DISTINCT
id
)
as
num
FROM
online
.
tl_hdfs_answer_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--and is_online = 'true'
AND
is_spam
=
'false'
--排除疑似广告
AND
platform
=
'99'
--更美用户发的(去除hera后台,爬虫爬取的,kyc自动回复的)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
),
'answer'
)
a
...
...
@@ -681,8 +680,8 @@ LEFT JOIN
(
SELECT
partition_date
,
user_id
,
device_id
,
action
FROM
online
.
bl_hdfs_operation_updates
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
a
JOIN
(
...
...
@@ -704,13 +703,13 @@ LEFT JOIN
--医生账号
SELECT
user_id
FROM
online
.
tl_hdfs_doctor_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--马甲账号/模特用户
UNION
ALL
SELECT
user_id
FROM
ml
.
ml_c_ct_ui_user_dimen_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
(
is_puppet
=
'true'
or
is_classifyuser
=
'true'
)
UNION
ALL
...
...
@@ -726,13 +725,13 @@ LEFT JOIN
SELECT
user_id
,
v
.
device_id
as
device_id
FROM
online
.
ml_user_history_detail
LATERAL
VIEW
EXPLODE
(
device_history_list
)
v
AS
device_id
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
t1
JOIN
(
SELECT
device_id
FROM
online
.
ml_device_history_detail
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
is_login_doctor
=
'1'
)
t2
ON
t1
.
device_id
=
t2
.
device_id
...
...
@@ -747,8 +746,8 @@ LEFT JOIN
SELECT
t
.
user_id
,
partition_date
,
if
(
size
(
t
.
device_list
)
>
0
,
device_list
[
0
],
''
)
device_id
FROM
online
.
ml_user_updates
t
WHERE
t
.
partition_date
>=
'${start_date}'
and
t
.
partition_date
<
'${end_date}'
WHERE
t
.
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
t
.
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
d
ON
a
.
user_id
=
d
.
user_id
AND
a
.
create_date
=
d
.
partition_date
...
...
@@ -773,21 +772,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -828,17 +827,17 @@ LEFT JOIN
(
SELECT
user_id
,
regexp_replace
(
substr
(
reply_date
,
1
,
10
),
'-'
,
''
)
as
reply_date
,
problem_id
,
count
(
reply_date
)
as
reply_num
FROM
online
.
tl_hdfs_topicreply_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
is_spam
=
'false'
--排除疑似广告
and
regexp_replace
(
substr
(
reply_date
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
reply_date
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
reply_date
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
reply_date
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
group
by
user_id
,
regexp_replace
(
substr
(
reply_date
,
1
,
10
),
'-'
,
''
),
problem_id
)
t1
JOIN
(
SELECT
id
,
diary_id
FROM
online
.
tl_hdfs_problem_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
group
by
id
,
diary_id
)
t2
on
t2
.
id
=
t1
.
problem_id
...
...
@@ -853,11 +852,11 @@ LEFT JOIN
(
SELECT
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
reply_date
,
count
(
create_time
)
as
reply_num
,
answer_id
FROM
online
.
tl_hdfs_answer_reply_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
(
is_fake
is
NULL
or
is_fake
=
'false'
)
AND
answer_id
is
not
NULL
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
group
by
user_id
,
answer_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
)
t2
GROUP
BY
t2
.
user_id
,
t2
.
reply_date
...
...
@@ -867,9 +866,9 @@ LEFT JOIN
--有评论过用户帖的设备
SELECT
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
as
reply_date
,
count
(
create_time
)
as
reply_num
FROM
online
.
tl_hdfs_api_tractate_reply_view
WHERE
partition_date
=
'${partition_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
by
user_id
,
regexp_replace
(
substr
(
create_time
,
1
,
10
),
'-'
,
''
)
)
reply_user
GROUP
BY
user_id
,
reply_date
...
...
@@ -882,8 +881,8 @@ LEFT JOIN
(
SELECT
partition_date
,
user_id
,
device_id
,
action
FROM
online
.
bl_hdfs_operation_updates
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
a
JOIN
(
...
...
@@ -905,13 +904,13 @@ LEFT JOIN
--医生账号
SELECT
user_id
FROM
online
.
tl_hdfs_doctor_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--马甲账号/模特用户
UNION
ALL
SELECT
user_id
FROM
ml
.
ml_c_ct_ui_user_dimen_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
(
is_puppet
=
'true'
or
is_classifyuser
=
'true'
)
UNION
ALL
...
...
@@ -927,13 +926,13 @@ LEFT JOIN
SELECT
user_id
,
v
.
device_id
as
device_id
FROM
online
.
ml_user_history_detail
LATERAL
VIEW
EXPLODE
(
device_history_list
)
v
AS
device_id
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
t1
JOIN
(
SELECT
device_id
FROM
online
.
ml_device_history_detail
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
is_login_doctor
=
'1'
)
t2
ON
t1
.
device_id
=
t2
.
device_id
...
...
@@ -947,8 +946,8 @@ LEFT JOIN
SELECT
t
.
user_id
,
partition_date
,
if
(
size
(
t
.
device_list
)
>
0
,
device_list
[
0
],
''
)
device_id
FROM
online
.
ml_user_updates
t
WHERE
t
.
partition_date
>=
'${start_date}'
and
t
.
partition_date
<
'${end_date}'
WHERE
t
.
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
t
.
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
d
ON
a
.
user_id
=
d
.
user_id
AND
a
.
reply_date
=
d
.
partition_date
...
...
@@ -973,21 +972,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -1019,8 +1018,8 @@ LEFT JOIN
(
SELECT
cl_id
,
partition_date
,
cl_type
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
action
=
'notification_open'
--推送点击
)
a
JOIN
...
...
@@ -1043,21 +1042,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -1092,7 +1091,7 @@ LEFT JOIN
(
SELECT
partition_date
,
cl_id
,
max
(
time_str
)
as
max_time_str
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
action
=
'is_open_push'
group
by
partition_date
,
cl_id
)
a
...
...
@@ -1100,7 +1099,7 @@ LEFT JOIN
(
SELECT
partition_date
,
cl_id
,
time_str
,
COALESCE
(
params
[
'type'
],
params
[
'tyep'
])
as
type
FROM
online
.
bl_hdfs_maidian_updates
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
action
=
'is_open_push'
)
b
on
b
.
partition_date
=
a
.
partition_date
and
b
.
cl_id
=
a
.
cl_id
and
b
.
time_str
=
a
.
max_time_str
...
...
@@ -1112,7 +1111,7 @@ LEFT JOIN
select
concat_ws
(
'-'
,
substr
(
partition_day
,
1
,
4
),
substr
(
partition_day
,
5
,
2
),
substr
(
partition_day
,
7
,
2
))
as
partition_date
,
device_id
from
bl
.
bl_et_bg_trackingpushlog_inc_d
where
partition_day
>=
'20200521'
and
partition_day
<
'${end_date}'
where
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
group
by
partition_day
,
device_id
union
all
...
...
@@ -1123,7 +1122,7 @@ LEFT JOIN
(
SELECT
partition_date
,
registration_id
,
platform
,
mesid
FROM
online
.
tl_hdfs_auroracallback_view
--推送push的回调表
where
partition_da
te
>=
'20200521'
AND
partition_date
<
'${end_date}'
where
partition_da
y
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--and notification_state='true'--用户开启通知
and
callback_type
=
'0'
--送达回执
and
platform
=
'android'
...
...
@@ -1161,21 +1160,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -1214,7 +1213,7 @@ LEFT JOIN
select
partition_day
as
partition_date
,
device_id
,
msg_id
,
'ios'
as
device_os_type
from
bl
.
bl_et_bg_trackingpushlog_inc_d
where
partition_day
>=
'20200521'
and
partition_day
<
'${end_date}'
where
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
group
by
partition_day
,
device_id
,
msg_id
union
all
...
...
@@ -1224,7 +1223,7 @@ LEFT JOIN
(
SELECT
partition_date
,
registration_id
,
platform
,
mesid
FROM
online
.
tl_hdfs_auroracallback_view
--推送push的回调表
where
partition_date
>=
'20200521'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--and notification_state='true'--用户开启通知
and
callback_type
=
'0'
--送达回执
and
platform
=
'android'
...
...
@@ -1269,17 +1268,17 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
=
'${partition_date}'
)
tmp
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
m
.
first_channel_source_type
=
tmp
.
code
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
)
m
...
...
@@ -1290,7 +1289,7 @@ LEFT JOIN
(
select
msg_id
,
push_type
,
time_stamp
from
online
.
tl_hdfs_push2_new_view
--增量表
where
partition_date
>=
'${start_date}'
AND
partition_date
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
msg_id
,
push_type
,
time_stamp
)
c
on
a
.
msg_id
=
c
.
msg_id
...
...
@@ -1300,7 +1299,7 @@ LEFT JOIN
partition_date
,
device_id
from
online
.
ml_device_day_active_status
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'3'
)
)
d
on
a
.
partition_date
=
d
.
partition_date
and
a
.
device_id
=
d
.
device_id
...
...
@@ -1334,7 +1333,7 @@ LEFT JOIN
(
--推送点击
SELECT
partition_date
,
cl_id
,
time_str
,
params
[
'message_id'
]
as
message_id
,
time_stamp
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
action
=
'notification_open'
GROUP
BY
partition_date
,
cl_id
,
time_str
,
params
[
'message_id'
],
time_stamp
)
a
...
...
@@ -1342,7 +1341,7 @@ LEFT JOIN
(
SELECT
msg_id
,
push_type
,
time_stamp
FROM
online
.
tl_hdfs_push2_new_view
--增量表
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
msg_id
,
push_type
,
time_stamp
)
b
on
b
.
msg_id
=
a
.
message_id
...
...
@@ -1368,21 +1367,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
@@ -1415,16 +1414,16 @@ LEFT JOIN
SELECT
partition_date
,
device_id
,
a
.
user_id
as
user_id
FROM
online
.
ml_device_updates
LATERAL
VIEW
explode
(
user_list
)
a
as
user_id
WHERE
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
WHERE
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
t1
JOIN
(
SELECT
user_id
,
regexp_replace
(
substr
(
date_joined
,
1
,
10
),
'-'
,
''
)
as
date_joined
FROM
online
.
ml_user_history_detail
WHERE
partition_date
=
'${partition_date}'
AND
regexp_replace
(
substr
(
date_joined
,
1
,
10
),
'-'
,
''
)
>=
'${start_date}'
AND
regexp_replace
(
substr
(
date_joined
,
1
,
10
),
'-'
,
''
)
<
'${end_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
regexp_replace
(
substr
(
date_joined
,
1
,
10
),
'-'
,
''
)
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
regexp_replace
(
substr
(
date_joined
,
1
,
10
),
'-'
,
''
)
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
t2
ON
t2
.
user_id
=
t1
.
user_id
and
t2
.
date_joined
=
t1
.
partition_date
...
...
@@ -1432,7 +1431,7 @@ LEFT JOIN
(
SELECT
user_id
,
auth_type
,
phone
FROM
online
.
tl_hdfs_userextra_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
auth_type
=
'1'
)
t3
ON
t2
.
user_id
=
t3
.
user_id
...
...
@@ -1445,13 +1444,13 @@ LEFT JOIN
--医生账号
SELECT
user_id
FROM
online
.
tl_hdfs_doctor_view
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
--马甲账号/模特用户
UNION
ALL
SELECT
user_id
FROM
ml
.
ml_c_ct_ui_user_dimen_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
(
is_puppet
=
'true'
or
is_classifyuser
=
'true'
)
UNION
ALL
...
...
@@ -1467,13 +1466,13 @@ LEFT JOIN
SELECT
user_id
,
v
.
device_id
as
device_id
FROM
online
.
ml_user_history_detail
LATERAL
VIEW
EXPLODE
(
device_history_list
)
v
AS
device_id
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
t1
JOIN
(
SELECT
device_id
FROM
online
.
ml_device_history_detail
WHERE
partition_date
=
'${partition_date}'
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
is_login_doctor
=
'1'
)
t2
ON
t1
.
device_id
=
t2
.
device_id
...
...
@@ -1502,21 +1501,21 @@ LEFT JOIN
LEFT
JOIN
(
SELECT
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
partition_day
>=
'${start_date}'
and
partition_day
<
'${end_date}'
)
tmp
WHERE
partition_day
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
(
SELECT
DISTINCT
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
'${per_partition_date}'
)
a
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
2
),
'-'
,
''
)
)
a
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
SELECT
device_id
,
day_id
FROM
pm
.
tl_pm_channel_d
WHERE
partition_day
=
'${partition_date}'
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
GROUP
BY
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
'${start_date}'
AND
partition_date
<
'${end_date}'
where
partition_date
>=
regexp_replace
(
date_sub
(
current_date
,
30
),
'-'
,
''
)
AND
partition_date
<
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
and
first_channel_source_type
not
in
(
'yqxiu1'
,
'yqxiu2'
,
'yqxiu3'
,
'yqxiu4'
,
'yqxiu5'
,
'mxyc1'
,
'mxyc2'
,
'mxyc3'
,
'wanpu'
,
'jinshan'
,
'jx'
,
'maimai'
,
'zhuoyi'
,
'huatian'
,
'suopingjingling'
,
'mocha'
,
'mizhe'
,
'meika'
,
'lamabang'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment