Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tkdm
Project
Overview
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etl
tkdm
Commits
e72576d0
Commit
e72576d0
authored
8 years ago
by
mengdongxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
d681b333
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
tkdm_base_device_pay_info.sql
tkdm_base_device_pay_info.sql
+64
-0
No files found.
tkdm_base_device_pay_info.sql
0 → 100644
View file @
e72576d0
set
hive
.
skewjoin
.
key
=
100000
;
set
hive
.
optimize
.
skewjoin
=
true
;
set
hive
.
input
.
format
=
org
.
apache
.
hadoop
.
hive
.
ql
.
io
.
BucketizedHiveInputFormat
;
set
hive
.
optimize
.
bucketmapjoin
=
true
;
set
hive
.
optimize
.
bucketmapjoin
.
sortedmerge
=
true
;
insert
overwrite
table
tkdm
.
tkdm_base_device_pay_info
partition
(
ds
=
'2017-02-23'
)
select
/*+mapjoin(a)*/
nvl
(
b
.
appid
,
a
.
appid
)
as
appid
,
nvl
(
b
.
deviceid
,
a
.
deviceid
)
as
deviceid
,
nvl
(
b
.
first_payment_ds
,
'2017-02-23'
)
as
first_payment_ds
,
if
(
isnull
(
a
.
deviceid
),
'2017-02-23'
,
nvl
(
b
.
last_payment_ds
,
'1970-01-01'
))
as
last_payment_ds
,
nvl
(
b
.
num_payment_cnt
,
0
)
+
nvl
(
a
.
num_payment_cnt
,
0
)
as
num_payment_cnt
,
nvl
(
b
.
num_payment_day
,
0
)
+
nvl
(
a
.
num_payment_day
,
0
)
as
num_payment_day
,
round
(
nvl
(
b
.
amt_payment
,
0
)
+
nvl
(
a
.
amt_payment
,
0
),
2
)
as
amt_payment
from
(
select
appid
,
deviceid
,
round
(
sum
(
amount
),
2
)
as
amt_payment
,
count
(
1
)
as
num_payment_cnt
,
1
as
num_payment_day
from
tkio
.
tkio_mid_pay_day
where
ds
=
'2017-02-23'
and
deviceid
!=
'00000000-0000-0000-0000-000000000000'
and
deviceid
!=
''
and
deviceid
!=
'0'
group
by
appid
,
deviceid
distribute
by
appid
,
deviceid
)
a
full
join
(
select
appid
,
deviceid
,
first_payment_ds
,
last_payment_ds
,
num_payment_cnt
,
num_payment_day
,
amt_payment
from
tkdm
.
tkdm_base_device_pay_info
where
ds
=
date_sub
(
'2017-02-23'
,
1
)
)
b
on
a
.
appid
=
b
.
appid
and
a
.
deviceid
=
b
.
deviceid
use
tkdm
;
create
EXTERNAL
table
tkdm_base_device_pay_info
(
appid
string
,
deviceid
string
,
first_payment_ds
string
,
last_payment_ds
string
,
num_payment_cnt
int
,
num_payment_day
int
,
amt_payment
double
)
PARTITIONED
BY
(
ds
string
)
clustered
by
(
appid
,
deviceid
)
sorted
by
(
appid
,
deviceid
)
into
32
buckets
ROW
FORMAT
DELIMITED
FIELDS
TERMINATED
BY
'
\t
'
STORED
AS
ORC
location
's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_base_device_pay_info'
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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