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
edc47f3f
Commit
edc47f3f
authored
Aug 18, 2020
by
魏艺敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push codes
parent
60dfe610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
34 deletions
+51
-34
clue_daily.sql
pm/clue_daily/etl/clue_daily.sql
+51
-34
clue_daily.zip
pm/clue_daily/job/clue_daily.zip
+0
-0
No files found.
pm/clue_daily/etl/clue_daily.sql
View file @
edc47f3f
...
...
@@ -123,13 +123,13 @@ FROM
)
mas
left
join
(
--找出user_id当天活跃的第一个设备id
SELECT
user_id
,
partition_da
y
,
if
(
size
(
device_
id_list
)
>
0
,
device_id
_list
[
0
],
''
)
AS
device_id
FROM
ml
.
ml_c_ct_ui_user_dimen_inc_d
WHERE
partition_da
y
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_da
y
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
SELECT
user_id
,
partition_da
te
,
if
(
size
(
device_
list
)
>
0
,
device
_list
[
0
],
''
)
AS
device_id
FROM
online
.
ml_user_updates
WHERE
partition_da
te
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_da
te
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
)
a
on
mas
.
partition_date
=
a
.
partition_da
y
and
mas
.
device_id
=
a
.
device_id
on
mas
.
partition_date
=
a
.
partition_da
te
and
mas
.
device_id
=
a
.
device_id
left
join
(
--私信线索总数
SELECT
msg
.
partition_date
,
user_id
...
...
@@ -144,7 +144,7 @@ FROM
)
msg
GROUP
BY
msg
.
partition_date
,
user_id
)
t1
ON
a
.
partition_da
y
=
t1
.
partition_date
and
a
.
user_id
=
t1
.
user_id
ON
a
.
partition_da
te
=
t1
.
partition_date
and
a
.
user_id
=
t1
.
user_id
left
join
(
--有效私信线索总数
SELECT
msg
.
partition_date
,
user_id
...
...
@@ -160,7 +160,7 @@ FROM
)
msg
GROUP
BY
msg
.
partition_date
,
user_id
)
t1_v
ON
a
.
partition_da
y
=
t1_v
.
partition_date
and
a
.
user_id
=
t1_v
.
user_id
ON
a
.
partition_da
te
=
t1_v
.
partition_date
and
a
.
user_id
=
t1_v
.
user_id
LEFT
JOIN
(
--电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
AS
clue_num
...
...
@@ -175,7 +175,7 @@ FROM
)
a
GROUP
BY
partition_date
,
user_id
)
t2
ON
a
.
partition_da
y
=
t2
.
partition_date
and
a
.
user_id
=
t2
.
user_id
ON
a
.
partition_da
te
=
t2
.
partition_date
and
a
.
user_id
=
t2
.
user_id
left
join
(
--kyc私信
...
...
@@ -206,7 +206,7 @@ FROM
)
msg
group
by
msg
.
partition_date
,
user_id
)
t4
on
a
.
partition_da
y
=
t4
.
partition_date
and
a
.
user_id
=
t4
.
user_id
on
a
.
partition_da
te
=
t4
.
partition_date
and
a
.
user_id
=
t4
.
user_id
left
join
(
--kyc有效私信
SELECT
msg
.
partition_date
,
user_id
...
...
@@ -237,7 +237,7 @@ FROM
)
msg
group
by
msg
.
partition_date
,
user_id
)
t4_v
on
a
.
partition_da
y
=
t4_v
.
partition_date
and
a
.
user_id
=
t4_v
.
user_id
on
a
.
partition_da
te
=
t4_v
.
partition_date
and
a
.
user_id
=
t4_v
.
user_id
LEFT
JOIN
(
--kyc电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
as
clue_num
...
...
@@ -288,7 +288,7 @@ FROM
)
a
group
by
partition_date
,
user_id
)
t5
ON
a
.
partition_da
y
=
t5
.
partition_date
and
a
.
user_id
=
t5
.
user_id
ON
a
.
partition_da
te
=
t5
.
partition_date
and
a
.
user_id
=
t5
.
user_id
left
join
(
--需求自测私信
...
...
@@ -342,7 +342,7 @@ FROM
)
msg
group
by
msg
.
partition_date
,
user_id
)
t7
on
a
.
partition_da
y
=
t7
.
partition_date
and
a
.
user_id
=
t7
.
user_id
on
a
.
partition_da
te
=
t7
.
partition_date
and
a
.
user_id
=
t7
.
user_id
left
join
(
--需求自测有效私信
SELECT
msg
.
partition_date
,
user_id
...
...
@@ -396,7 +396,7 @@ FROM
)
msg
group
by
msg
.
partition_date
,
user_id
)
t7_v
on
a
.
partition_da
y
=
t7_v
.
partition_date
and
a
.
user_id
=
t7_v
.
user_id
on
a
.
partition_da
te
=
t7_v
.
partition_date
and
a
.
user_id
=
t7_v
.
user_id
LEFT
JOIN
(
--需求自测电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
as
clue_num
...
...
@@ -429,7 +429,7 @@ FROM
)
a
group
by
partition_date
,
user_id
)
t8
ON
a
.
partition_da
y
=
t8
.
partition_date
and
a
.
user_id
=
t8
.
user_id
ON
a
.
partition_da
te
=
t8
.
partition_date
and
a
.
user_id
=
t8
.
user_id
left
join
(
--t4以上商户私信线索总数
...
...
@@ -459,7 +459,7 @@ FROM
on
msg
.
merchant_id
=
b
.
merchant_id
GROUP
BY
msg
.
partition_date
,
user_id
)
t10
ON
a
.
partition_da
y
=
t10
.
partition_date
and
a
.
user_id
=
t10
.
user_id
ON
a
.
partition_da
te
=
t10
.
partition_date
and
a
.
user_id
=
t10
.
user_id
left
join
(
--t4以上商户有效私信线索总数
SELECT
msg
.
partition_date
,
user_id
...
...
@@ -489,7 +489,7 @@ FROM
on
msg
.
merchant_id
=
b
.
merchant_id
GROUP
BY
msg
.
partition_date
,
user_id
)
t10_v
ON
a
.
partition_da
y
=
t10_v
.
partition_date
and
a
.
user_id
=
t10_v
.
user_id
ON
a
.
partition_da
te
=
t10_v
.
partition_date
and
a
.
user_id
=
t10_v
.
user_id
left
join
(
--t4以上商户电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
AS
clue_num
...
...
@@ -518,13 +518,15 @@ FROM
on
a
.
merchant_id
=
b
.
merchant_id
GROUP
BY
partition_date
,
user_id
)
t11
ON
a
.
partition_da
y
=
t11
.
partition_date
and
a
.
user_id
=
t11
.
user_id
ON
a
.
partition_da
te
=
t11
.
partition_date
and
a
.
user_id
=
t11
.
user_id
group
by
mas
.
partition_date
,
device_os_type
,
active_type
,
grey_type
)
T1
LEFT
JOIN
(
SELECT
t3
.
partition_date
,
a
.
device_os_type
,
'老活跃设备'
as
active_type
,
a
.
grey_type
,
count
(
distinct
case
when
t3
.
call_num
>
0
then
t3
.
user_id
end
)
as
call_dev
SELECT
t3
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
,
case
when
b
.
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
when
(
b
.
active_type
=
'4'
or
b
.
active_type
is
null
)
then
'老活跃设备'
end
as
active_type
,
count
(
distinct
case
when
t3
.
call_num
>
0
then
t3
.
user_id
end
)
as
call_dev
,
sum
(
t3
.
call_num
)
as
call_num
,
count
(
distinct
case
when
t3_v
.
valid_call_num
>
0
then
t3_v
.
user_id
end
)
as
valid_call_dev
,
sum
(
t3_v
.
valid_call_num
)
as
valid_call_num
...
...
@@ -553,24 +555,25 @@ LEFT JOIN
,
array
(
case
when
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
2
,
2
)
%
20
=
0
then
'kyc灰度'
else
'非灰'
end
,
'合计'
)
as
grey_type
FROM
(
SELECT
device_id
,
device_os_type
,
a
.
user_id
,
row_number
()
over
(
partition
by
device_id
order
by
a
.
partition_da
y
desc
)
as
rn
SELECT
device_id
,
device_os_type
,
a
.
user_id
,
a
.
partition_date
,
row_number
()
over
(
partition
by
device_id
order
by
a
.
partition_da
te
desc
)
as
rn
FROM
(
SELECT
device_id
,
device_os_type
,
v
.
user_id
,
partition_day
FROM
ml
.
mid_ml_c_ct_dv_device_inc_d
LATERAL
VIEW
EXPLODE
(
user_id_list
)
v
as
user_id
where
partition_day
>=
'20200801'
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
SELECT
device_id
,
v
.
device_os_type
,
v
.
user_id
,
partition_date
FROM
online
.
ml_device_updates
LATERAL
VIEW
EXPLODE
(
user_list
)
v
as
user_id
LATERAL
VIEW
EXPLODE
(
device_os_type
)
v
as
device_os_type
where
partition_date
>=
'20200801'
and
partition_date
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
)
a
--由于要取近期该设备用过的user_id,故时间取的较长,避免用公式而将月末数据少算
join
(
SELECT
partition_da
y
,
user_id
FROM
ml
.
ml_c_ct_ui_user_dimen_inc_d
where
partition_da
y
>=
'20200801'
and
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
and
size
(
user_phone_list
)
>
0
group
by
partition_da
y
,
user_id
SELECT
partition_da
te
,
user_id
FROM
online
.
ml_user_updates
where
partition_da
te
>=
'20200801'
and
partition_date
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
and
phone
is
not
null
and
phone
<>
''
group
by
partition_da
te
,
user_id
)
b
on
a
.
partition_da
y
=
b
.
partition_day
and
a
.
user_id
=
b
.
user_id
on
a
.
partition_da
te
=
b
.
partition_date
and
a
.
user_id
=
b
.
user_id
)
c
where
rn
=
1
)
d
...
...
@@ -628,6 +631,18 @@ LEFT JOIN
GROUP
BY
user_id
,
partition_date
)
t3
ON
a
.
user_id
=
t3
.
user_id
left
join
(
SELECT
partition_date
,
device_id
,
active_type
FROM
online
.
ml_device_day_active_status
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
)
b
on
t3
.
partition_date
=
b
.
partition_date
and
a
.
device_id
=
b
.
device_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
...
...
@@ -1120,9 +1135,10 @@ LEFT JOIN
GROUP
BY
user_id
,
partition_date
)
t12_v
ON
t3
.
partition_date
=
t12_v
.
partition_date
and
t3
.
user_id
=
t12_v
.
user_id
group
by
t3
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
group
by
t3
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
,
case
when
b
.
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
when
(
b
.
active_type
=
'4'
or
b
.
active_type
is
null
)
then
'老活跃设备'
end
)
T2
on
T1
.
partition_date
=
T2
.
partition_date
AND
T1
.
device_os_type
=
T2
.
device_os_type
AND
T1
.
active_type
=
T2
.
active_type
AND
T1
.
grey_type
=
T2
.
grey_type
;
AND
T1
.
grey_type
=
T2
.
grey_type
\ No newline at end of file
pm/clue_daily/job/clue_daily.zip
View file @
edc47f3f
No preview for this file type
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