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
837ff895
Commit
837ff895
authored
Aug 18, 2020
by
魏艺敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push codes
parent
a12d8dad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
46 deletions
+46
-46
daily_recommend_strategy.sql
pm/daily_recommend_strategy/etl/daily_recommend_strategy.sql
+46
-46
No files found.
pm/daily_recommend_strategy/etl/daily_recommend_strategy.sql
View file @
837ff895
...
...
@@ -37,7 +37,7 @@ FROM
WHEN
active_type
IN
(
'1'
,
'2'
)
THEN
'新增'
END
AS
active_type
,
device_id
FROM
online
.
ml_device_day_active_status
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
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'
...
...
@@ -53,7 +53,7 @@ FROM
SELECT
partition_date
,
card_content_type
,
cl_id
,
recommend_type
,
v
.
recommend_type
,
card_id
,
count
(
distinct
app_session_id
)
as
session_pv
FROM
...
...
@@ -61,18 +61,17 @@ FROM
SELECT
partition_date
,
cl_id
,
case
when
card_content_type
in
(
'qa'
,
'answer'
)
then
'qa'
else
card_content_type
end
as
card_content_type
,
CASE
when
transaction_type
in
(
'fmctr'
)
then
'fmctr'
WHEN
transaction_type
like
'%ctr'
THEN
'ctr预估'
WHEN
transaction_type
like
'%cvr'
THEN
'cvr预估'
WHEN
transaction_type
in
(
'-1'
,
'smr'
)
THEN
'smr'
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
'热点卡片'
when
transaction_type
in
(
'newdata'
)
then
'保量卡片'
when
transaction_type
in
(
'hotspot_feed'
)
then
'hotspot_feed'
END
AS
recommend_type
,
CASE
when
transaction_type
in
(
'fmctr'
)
then
array
(
'fmctr'
,
'合计'
)
WHEN
transaction_type
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
transaction_type
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
transaction_type
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
transaction_type
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
transaction_type
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
end
AS
recommend_type
,
card_id
,
app_session_id
from
online
.
ml_community_precise_exposure_detail
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
in
(
'page_precise_exposure'
,
'home_choiceness_card_exposure'
)
--7745版本action改为page_precise_exposure
AND
is_exposure
=
'1'
----精准曝光
AND
page_name
=
'home'
...
...
@@ -83,17 +82,18 @@ FROM
group
by
partition_date
,
case
when
card_content_type
in
(
'qa'
,
'answer'
)
then
'qa'
else
card_content_type
end
,
cl_id
,
CASE
when
transaction_type
in
(
'fmctr'
)
then
'fmctr'
WHEN
transaction_type
like
'%ctr'
THEN
'ctr预估'
WHEN
transaction_type
like
'%cvr'
THEN
'cvr预估'
WHEN
transaction_type
in
(
'-1'
,
'smr'
)
THEN
'smr'
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
'热点卡片'
when
transaction_type
in
(
'newdata'
)
then
'保量卡片'
when
transaction_type
in
(
'hotspot_feed'
)
then
'hotspot_feed'
END
,
CASE
when
transaction_type
in
(
'fmctr'
)
then
array
(
'fmctr'
,
'合计'
)
WHEN
transaction_type
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
transaction_type
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
transaction_type
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
transaction_type
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
transaction_type
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
transaction_type
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
end
,
card_id
,
app_session_id
)
a
group
by
partition_date
,
card_content_type
,
cl_id
,
recommend_type
,
card_id
LATERAL
VIEW
explode
(
a
.
recommend_type
)
v
as
recommend_type
group
by
partition_date
,
card_content_type
,
cl_id
,
v
.
recommend_type
,
card_id
)
t2
on
t1
.
device_id
=
t2
.
cl_id
and
t1
.
partition_date
=
t2
.
partition_date
LEFT
JOIN
...
...
@@ -101,7 +101,7 @@ FROM
SELECT
partition_date
,
card_content_type
,
cl_id
,
recommend_type
,
v
.
recommend_type
,
card_id
,
count
(
distinct
app_session_id
)
as
session_pv
FROM
...
...
@@ -109,18 +109,17 @@ FROM
SELECT
partition_date
,
cl_id
,
case
when
params
[
'card_content_type'
]
in
(
'qa'
,
'answer'
)
then
'qa'
else
params
[
'card_content_type'
]
end
as
card_content_type
,
CASE
when
params
[
'transaction_type'
]
in
(
'fmctr'
)
then
'fmctr'
WHEN
params
[
'transaction_type'
]
like
'%ctr'
THEN
'ctr预估'
WHEN
params
[
'transaction_type'
]
like
'%cvr'
THEN
'cvr预估'
WHEN
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
)
THEN
'smr'
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
'热点卡片'
when
params
[
'transaction_type'
]
in
(
'newdata'
)
then
'保量卡片'
when
params
[
'transaction_type'
]
in
(
'hotspot_feed'
)
then
'hotspot_feed'
END
AS
recommend_type
,
CASE
when
params
[
'transaction_type'
]
in
(
'fmctr'
)
then
array
(
'fmctr'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
params
[
'transaction_type'
]
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
end
AS
recommend_type
,
params
[
'card_id'
]
as
card_id
,
app_session_id
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_card'
AND
params
[
'page_name'
]
=
'home'
AND
params
[
'tab_name'
]
=
'精选'
...
...
@@ -130,17 +129,18 @@ FROM
GROUP
BY
partition_date
,
cl_id
,
case
when
params
[
'card_content_type'
]
in
(
'qa'
,
'answer'
)
then
'qa'
else
params
[
'card_content_type'
]
end
,
CASE
when
params
[
'transaction_type'
]
in
(
'fmctr'
)
then
'fmctr'
WHEN
params
[
'transaction_type'
]
like
'%ctr'
THEN
'ctr预估'
WHEN
params
[
'transaction_type'
]
like
'%cvr'
THEN
'cvr预估'
WHEN
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
)
THEN
'smr'
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
'热点卡片'
when
params
[
'transaction_type'
]
in
(
'newdata'
)
then
'保量卡片'
when
params
[
'transaction_type'
]
in
(
'hotspot_feed'
)
then
'hotspot_feed'
END
,
CASE
when
params
[
'transaction_type'
]
in
(
'fmctr'
)
then
array
(
'fmctr'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
like
'%ctr'
THEN
array
(
'ctr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
like
'%cvr'
THEN
array
(
'cvr预估'
,
'合计'
)
WHEN
params
[
'transaction_type'
]
in
(
'-1'
,
'smr'
)
THEN
array
(
'smr'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'pgc'
,
'hotspot'
)
then
array
(
'热点卡片'
,
'合计'
)
when
params
[
'transaction_type'
]
in
(
'newdata'
)
then
array
(
'保量卡片'
)
when
params
[
'transaction_type'
]
in
(
'hotspot_feed'
)
then
array
(
'hotspot_feed'
,
'合计'
)
end
,
params
[
'card_id'
],
app_session_id
)
a
group
by
partition_date
,
card_content_type
,
cl_id
,
recommend_type
,
card_id
LATERAL
VIEW
explode
(
a
.
recommend_type
)
v
as
recommend_type
group
by
partition_date
,
card_content_type
,
cl_id
,
v
.
recommend_type
,
card_id
)
t3
on
t2
.
partition_date
=
t3
.
partition_date
and
t2
.
cl_id
=
t3
.
cl_id
...
...
@@ -155,7 +155,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
sum
(
page_stay
)
as
page_stay
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
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'
)
AND
referrer
=
'home'
...
...
@@ -177,7 +177,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
navbar_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
in
(
'on_click_navbar_search'
,
'do_search'
)
AND
page_name
IN
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
AND
(
referrer
=
'home'
or
...
...
@@ -200,7 +200,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
highlight_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_card'
and
params
[
'card_type'
]
=
'highlight_word'
AND
page_name
IN
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
...
...
@@ -227,7 +227,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
(
get_json_object
(
params
[
'extra_param'
],
'$.type'
)
=
'交互栏'
or
get_json_object
(
params
[
'extra_param'
],
'$.jump_from'
)
=
'msg_link'
or
params
[
'in_page_pos'
]
=
'top'
...
...
@@ -261,7 +261,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
service_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
(
action
=
'on_click_card'
and
params
[
'card_content_type'
]
=
'service'
or
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'unfold'
and
page_name
in
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
)
or
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'more_recommendations'
)
...
...
@@ -291,7 +291,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
service_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_card'
and
params
[
'card_content_type'
]
in
(
'qa'
,
'diary'
,
'user_post'
,
'answer'
)
AND
page_name
IN
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
...
...
@@ -317,7 +317,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
video_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'video_interview'
AND
page_name
IN
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
...
...
@@ -341,7 +341,7 @@ FROM
when
page_name
in
(
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
then
'qa'
else
null
end
as
page_name
,
count
(
1
)
as
referral_pv
FROM
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
AND
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'referral'
AND
page_name
IN
(
'diary_detail'
,
'topic_detail'
,
'post_detail'
,
'user_post_detail'
,
'doctor_post_detail'
,
'question_detail'
,
'answer_detail'
,
'question_answer_detail'
)
...
...
@@ -377,7 +377,7 @@ FROM
SELECT
user_id
,
partition_date
,
if
(
size
(
device_list
)
>
0
,
device_list
[
0
],
''
)
AS
device_id
FROM
online
.
ml_user_updates
WHERE
partition_date
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
WHERE
partition_date
>=
'20200101'
and
partition_date
<
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
)
t1
JOIN
(
--医生账号
...
...
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