CREATE TABLE adv_appsflyer.appsflyer_metrics
(

    `data_date` Int64 COMMENT '日期 20190228',

    `data_hour` Int64 COMMENT '小时 13',

    `time_zone` String COMMENT '时区 +0900',

    `region` String DEFAULT 'KR' COMMENT '韩国KR,
香港 HK,
台湾 TW,
其它：-1，或者其它值',

    `platform` String COMMENT '平台 Android|IOS',

    `game_id` String COMMENT '游戏ID bundle_id,com.edgames.new19gp',

    `channel` String DEFAULT '-1',

    `media_source` String COMMENT '媒体平台 googleadwords_int',

    `campaign_id` String COMMENT '广告系列ID 23843308705120641',

    `ad_set_id` String COMMENT '广告组|计划ID 23843308705230641',

    `ad_id` String COMMENT '广告ID 23843308708070641',
    
    `data_type` Int8 DEFAULT '0' COMMENT '1.新增 2.再营销 3.预注册',

    `data_activation` Int64 DEFAULT '0' COMMENT '激活数 按唯一设备去重 ',

    `data_register` Int64 DEFAULT '0' COMMENT '注册数 按唯一用户去重',

    `data_day_act_register` Int64 DEFAULT '0' COMMENT '当日激活 并且当日注册数',

    `data_device_register` Int64 DEFAULT '0' COMMENT '设备注册数',

    `data_create_role` Int32 DEFAULT '0' COMMENT '创角数',

    `data_day_register_create` Int32 DEFAULT '0' COMMENT '当日注册 并且当日创角数',

    `data_active_day_dau` Int32 DEFAULT '0' COMMENT '当日登录用户，排除当日注册用户',
    
    `data_active_2day` Int64 DEFAULT '0' COMMENT '次日活跃|留存',
`data_active_3day` Int64 DEFAULT '0' COMMENT '3日活跃|留存',
`data_active_7day` Int64 DEFAULT '0' COMMENT '7日活跃|留存',
`data_active_15day` Int64 DEFAULT '0' COMMENT '15日活跃|留存',
`data_active_30day` Int64 DEFAULT '0' COMMENT '30日活跃|留存'
)
ENGINE = SummingMergeTree()
PARTITION BY intDiv(data_date , 100)
ORDER BY (data_date,
data_hour,
time_zone,
region,
platform,
game_id,
channel,
media_source,
campaign_id,
ad_set_id,
ad_id,
data_type)
SETTINGS index_granularity = 8192

INSERT into appsflyer_metrics
select  data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,data_activation,data_register,
data_day_act_register,data_device_register,data_create_role,data_day_register_create,data_active_day_dau,data_active_2day,data_active_3day,
data_active_7day,data_active_15day,data_active_30day
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')

INSERT into appsflyer_metrics
( data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,data_activation)
select  data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,re_engagement as data_activation
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')




CREATE TABLE adv_appsflyer.appsflyer_pay_record
(

    `did` String DEFAULT '-1',

    `uid` String COMMENT '用户ID,
appsflyer_device_id',

    `game_id` String COMMENT '游戏ID bundle_id com.edgames.new19gp',
    
    `region` String DEFAULT 'KR' COMMENT '韩国KR',

    `platform` String COMMENT '平台 Android|IOS',

    `media_source` String COMMENT '媒体平台 googleadwords_int',

    `campaign_id` String COMMENT '广告系列ID 23843308705120641',

    `ad_set_id` String DEFAULT '-1' COMMENT '广告组|计划ID 23843308705230641',

    `ad_id` String DEFAULT '-1' COMMENT '广告ID 23843308708070641',

    `channel` Nullable(String) COMMENT 'channel',

    `currency` String DEFAULT 'KRW' COMMENT '货币类型',

    `data_type` Int8 ,
    
    `money` Float64 COMMENT '支付金额',

    `order_no` String COMMENT '订单编号',
    
    `pay_time` DateTime COMMENT '支付时间 2019-02-28 00:07:06',
    
    `activation_time` DateTime COMMENT '激活时间',

    `reg_time` Nullable(DateTime) COMMENT '注册时间',

    `time_zone` String DEFAULT '+0900' COMMENT '时区'
)
ENGINE = ReplacingMergeTree
PARTITION BY toYYYYMM(pay_time)
ORDER BY (uid,
game_id,
pay_time,
platform,
media_source,
campaign_id,
ad_set_id,
ad_id,
order_no,)
SETTINGS index_granularity = 8192

UPDATE appsflyer_pay_record t1,appsflyer_activation_devices t2 set t1.activation_time = t2.activation_time WHERE t1.uid = t2.uid

INSERT into appsflyer_pay_record select
did,uid,game_id,region,platform,media_source,campaign_id,ad_set_id,ad_id,channel,currency,'1',money,order_no,pay_time,
activation_time, reg_time,time_zone
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_pay_record', 'appsflyer', 'SDFKKJ#%#23sf1632') WHERE activation_time is NOT NULL AND toDate(activation_time) is NOT NULL;


//物化视图 ltv

CREATE MATERIALIZED VIEW IF NOT EXISTS appsflyer_order_accumulative_view

ENGINE = SummingMergeTree
PARTITION BY game_id
ORDER BY (ds, game_id, platform, media_source, campaign_id, ad_set_id, ad_id, currency,region)
POPULATE
AS SELECT toYYYYMMDD(activation_time) as ds,  game_id, platform, media_source, campaign_id, ad_set_id, ad_id, currency,region,
sum( IF(dateDiff('day',activation_time,now())>=0  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)=0  and money  IS NOT NULL ,money ,0  )) as day0_sum ,  
sum( IF(dateDiff('day',activation_time,now())>=1  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=1 and money  IS NOT NULL ,money ,0  )) as day1_sum ,
sum( IF(dateDiff('day',activation_time,now())>=2  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=2 and money  IS NOT NULL ,money ,0  )) as day2_sum ,
sum( IF(dateDiff('day',activation_time,now())>=3  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=3 and money  IS NOT NULL ,money ,0  )) as day3_sum ,
sum( IF(dateDiff('day',activation_time,now())>=4  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=4 and money  IS NOT NULL ,money ,0  )) as day4_sum ,
sum( IF(dateDiff('day',activation_time,now())>=5  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=5 and money  IS NOT NULL ,money ,0  )) as day5_sum ,
sum( IF(dateDiff('day',activation_time,now())>=6  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=6 and money  IS NOT NULL ,money ,0  )) as day6_sum ,
sum( IF(dateDiff('day',activation_time,now())>=7  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=7 and money  IS NOT NULL ,money ,0  )) as day7_sum ,
sum( IF(dateDiff('day',activation_time,now())>=8  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=8 and money  IS NOT NULL ,money ,0  )) as day8_sum ,
sum( IF(dateDiff('day',activation_time,now())>=9  and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=9 and money  IS NOT NULL ,money ,0  )) as day9_sum ,
sum( IF(dateDiff('day',activation_time,now())>=10 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=10 and money  IS NOT NULL ,money ,0 )) as day10_sum ,
sum( IF(dateDiff('day',activation_time,now())>=11 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=11 and money  IS NOT NULL ,money ,0 )) as day11_sum ,
sum( IF(dateDiff('day',activation_time,now())>=12 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=12 and money  IS NOT NULL ,money ,0 )) as day12_sum ,
sum( IF(dateDiff('day',activation_time,now())>=13 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=13 and money  IS NOT NULL ,money ,0 )) as day13_sum ,
sum( IF(dateDiff('day',activation_time,now())>=14 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=14 and money  IS NOT NULL ,money ,0 )) as day14_sum ,
sum( IF(dateDiff('day',activation_time,now())>=15 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=15 and money  IS NOT NULL ,money ,0 )) as day15_sum ,
sum( IF(dateDiff('day',activation_time,now())>=20 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=20 and money  IS NOT NULL ,money ,0 )) as day20_sum ,
sum( IF(dateDiff('day',activation_time,now())>=25 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=25 and money  IS NOT NULL ,money ,0 )) as day25_sum ,
sum( IF(dateDiff('day',activation_time,now())>=30 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=30 and money  IS NOT NULL ,money ,0 )) as day30_sum ,
sum( IF(dateDiff('day',activation_time,now())>=35 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=35 and money  IS NOT NULL ,money ,0 )) as day35_sum ,
sum( IF(dateDiff('day',activation_time,now())>=40 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=40 and money  IS NOT NULL ,money ,0 )) as day40_sum ,
sum( IF(dateDiff('day',activation_time,now())>=45 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=45 and money  IS NOT NULL ,money ,0 )) as day45_sum ,
sum( IF(dateDiff('day',activation_time,now())>=50 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=50 and money  IS NOT NULL ,money ,0 )) as day50_sum ,
sum( IF(dateDiff('day',activation_time,now())>=55 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=55 and money  IS NOT NULL ,money ,0 )) as day55_sum ,
sum( IF(dateDiff('day',activation_time,now())>=60 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=60 and money  IS NOT NULL ,money ,0 )) as day60_sum ,
sum( IF(dateDiff('day',activation_time,now())>=65 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=65 and money  IS NOT NULL ,money ,0 )) as day65_sum ,
sum( IF(dateDiff('day',activation_time,now())>=70 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=70 and money  IS NOT NULL ,money ,0 )) as day70_sum ,
sum( IF(dateDiff('day',activation_time,now())>=75 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=75 and money  IS NOT NULL ,money ,0 )) as day75_sum ,
sum( IF(dateDiff('day',activation_time,now())>=80 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=80 and money  IS NOT NULL ,money ,0 )) as day80_sum ,
sum( IF(dateDiff('day',activation_time,now())>=85 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=85 and money  IS NOT NULL ,money ,0 )) as day85_sum ,
sum( IF(dateDiff('day',activation_time,now())>=90 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=90 and money  IS NOT NULL ,money ,0 )) as day90_sum ,
sum( IF(dateDiff('day',activation_time,now())>=120 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=120 and money  IS NOT NULL ,money ,0 )) as day120_sum ,
sum( IF(dateDiff('day',activation_time,now())>=150 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=150 and money  IS NOT NULL ,money ,0 )) as day150_sum ,
sum( IF(dateDiff('day',activation_time,now())>=180 and activation_time<=pay_time and dateDiff('day',activation_time,pay_time)<=180 and money  IS NOT NULL ,money ,0 )) as day180_sum ,

count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=0  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)=0  and uid is not null,uid ,null ))  as day0_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=1  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=1 and uid is not null,uid ,null ))  as day1_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=2  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=2 and uid is not null,uid ,null ))  as day2_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=3  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=3 and uid is not null,uid ,null ))  as day3_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=4  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=4 and uid is not null,uid ,null ))  as day4_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=5  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=5 and uid is not null,uid ,null ))  as day5_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=6  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=6 and uid is not null,uid ,null ))  as day6_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=7  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=7 and uid is not null,uid ,null ))  as day7_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=8  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=8 and uid is not null,uid ,null ))  as day8_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=9  and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=9 and uid is not null,uid ,null ))  as day9_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=10 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=10 and uid is not null,uid ,null )) as day10_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=11 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=11 and uid is not null,uid ,null )) as day11_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=12 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=12 and uid is not null,uid ,null )) as day12_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=13 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=13 and uid is not null,uid ,null )) as day13_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=14 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=14 and uid is not null,uid ,null )) as day14_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=15 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=15 and uid is not null,uid ,null )) as day15_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=20 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=20 and uid is not null,uid ,null )) as day20_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=25 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=25 and uid is not null,uid ,null )) as day25_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=30 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=30 and uid is not null,uid ,null )) as day30_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=35 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=35 and uid is not null,uid ,null )) as day35_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=40 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=40 and uid is not null,uid ,null )) as day40_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=45 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=45 and uid is not null,uid ,null )) as day45_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=50 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=50 and uid is not null,uid ,null )) as day50_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=55 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=55 and uid is not null,uid ,null )) as day55_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=60 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=60 and uid is not null,uid ,null )) as day60_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=65 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=65 and uid is not null,uid ,null )) as day65_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=70 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=70 and uid is not null,uid ,null )) as day70_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=75 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=75 and uid is not null,uid ,null )) as day75_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=80 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=80 and uid is not null,uid ,null )) as day80_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=85 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=85 and uid is not null,uid ,null )) as day85_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=90 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=90 and uid is not null,uid ,null )) as day90_num  ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=120 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=120 and uid is not null,uid ,null )) as day120_num ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=150 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=150 and uid is not null,uid ,null )) as day150_num ,
count(DISTINCT IF(DATEDIFF('day',activation_time,now())>=180 and  activation_time<=pay_time and DATEDIFF('day',activation_time,pay_time)<=180 and uid is not null,uid ,null )) as day180_num ,
sum(money) as day_now_sum,
count(DISTINCT(uid)) as day_now_num

from appsflyer_pay_record
GROUP BY toYYYYMMDD(activation_time), game_id, platform, media_source, campaign_id, ad_set_id, ad_id, currency ,region



//新的指标表
CREATE TABLE adv_appsflyer.appsflyer_metrics_detail
(
`uid` String COMMENT '用户id',

    `data_date` Int64 COMMENT '日期 20190228',

    `data_hour` Int16 COMMENT '小时 13',

    `time_zone` String COMMENT '时区 +0900',

    `region` String DEFAULT 'KR' COMMENT '韩国KR,
香港 HK,
台湾 TW,
其它：-1，或者其它值',


    `platform` String COMMENT '平台 Android|IOS',

    `game_id` String COMMENT '游戏ID bundle_id,
com.edgames.new19gp',

    `channel` String DEFAULT '-1',

    `media_source` String COMMENT '媒体平台 googleadwords_int',

    `campaign_id` String COMMENT '广告系列ID 23843308705120641',

    `ad_set_id` String COMMENT '广告组|计划ID 23843308705230641',

    `ad_id` String COMMENT '广告ID 23843308708070641',
    
    `data_type` Int8 DEFAULT '0' COMMENT '1.新增 2.再营销 3.预注册',
    
    `metric_name` String COMMENT '指标名称',
    
    `metric_value` Int64  COMMENT '指标值'
    
    )
ENGINE = MergeTree
PARTITION BY intDiv(data_date , 100)
ORDER BY ( uid,
data_date,
data_hour,
time_zone,
region,
platform,
game_id,
channel,
media_source,
campaign_id,
ad_set_id,
ad_id,
data_type,
metric_name)
SETTINGS index_granularity = 8192

//转移数据 列转行
INSERT into appsflyer_metrics_detail
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_activation',data_activation
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_register',data_register
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_day_act_register',data_day_act_register
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_device_register',data_device_register
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_create_role',data_create_role
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_day_register_create',data_day_register_create
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_active_day_dau',data_active_day_dau
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_active_2day',data_active_2day
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_active_3day',data_active_3day
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632');
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_active_7day',data_active_7day
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_active_15day',data_active_15day
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')
UNION ALL
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'data_active_30day',data_active_30day
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_metrics', 'appsflyer', 'SDFKKJ#%#23sf1632')

INSERT into appsflyer_metrics_detail
select -1 as uid ,data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,'retention_day1',SUM(retention_day1)
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_order_accumulative', 'appsflyer', 'SDFKKJ#%#23sf1632')


//物化视图 metric

CREATE MATERIALIZED VIEW IF NOT EXISTS appsflyer_metric_view
ENGINE = AggregatingMergeTree
PARTITION BY intDiv(data_date , 100)
ORDER BY (data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type)
POPULATE
AS select data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type,
SUM(IF(metric_name='data_view',metric_value,0)) AS data_view,
SUM(IF(metric_name='data_click',metric_value,0)) AS data_click,
SUM(IF(metric_name='data_activation',metric_value,0)) AS data_activation,
SUM(IF(metric_name='data_register',metric_value,0)) AS data_register,
SUM(IF(metric_name='data_day_act_register',metric_value,0)) AS data_day_act_register,
SUM(IF(metric_name='data_device_register',metric_value,0)) AS data_device_register,
SUM(IF(metric_name='data_create_role',metric_value,0)) AS data_create_role,
SUM(IF(metric_name='data_day_register_create',metric_value,0)) AS data_day_register_create,
SUM(IF(metric_name='data_active_day_dau',metric_value,0)) AS data_active_day_dau,
SUM(IF(metric_name='re_engagement',metric_value,0)) AS re_engagement,
SUM(IF(metric_name='re_attribution',metric_value,0)) AS re_attribution
from appsflyer_metrics_detail
group by data_date,data_hour,time_zone,region,platform,game_id,channel,media_source,campaign_id,ad_set_id, ad_id,data_type

// 激活表
CREATE TABLE `appsflyer_activation_devices` (
`platform` String  COMMENT '平台 Android|IOS',
`did` String  COMMENT '设备ID IMEI|IDFA',
`uid` String  DEFAULT '-1' COMMENT 'appfly device id',
`region` String  DEFAULT 'KR' COMMENT '韩国KR, 香港 HK, 台湾 TW, 其它：-1，或者其它值',
`game_id` String  COMMENT '游戏ID bundle_id com.edgames.new19gp',
`media_source` String  COMMENT '媒体平台 googleadwords_int',
`campaign_id` String  COMMENT '广告系列ID 23843308705120641',
`ad_set_id` String  DEFAULT '-1' COMMENT '广告组|计划ID 23843308705230641',
`ad_id` String  DEFAULT '-1' COMMENT '广告ID 23843308708070641',
`time_zone` String DEFAULT '+0900' COMMENT '时区',
`event_type` String COMMENT '类型',
`event_time` DateTime COMMENT '时间'
)
ENGINE = ReplacingMergeTree()
PARTITION BY toYYYYMM(event_time)
ORDER BY (`platform`,`game_id`,`uid`,`event_type`)
SETTINGS index_granularity = 8192

//激活表迁移数据
INSERT into appsflyer_activation_devices
select platform,did,uid,region,game_id,media_source,campaign_id,ad_set_id,ad_id,time_zone,'activation',reg_time
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_register_account', 'appsflyer', 'SDFKKJ#%#23sf1632') WHERE reg_time is NOT NULL;


INSERT into appsflyer_activation_devices
select platform,did,uid,region,game_id,media_source,campaign_id,ad_set_id,ad_id,time_zone,'activation',activation_time
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_activation_devices', 'appsflyer', 'SDFKKJ#%#23sf1632');



INSERT into appsflyer_activation_devices
select platform,did,uid,region,game_id,media_source,campaign_id,ad_set_id,ad_id,time_zone,'register',reg_time
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_register_account', 'appsflyer', 'SDFKKJ#%#23sf1632') WHERE reg_time is NOT NULL;

INSERT into appsflyer_activation_devices
select platform,did,uid,region,game_id,media_source,campaign_id,ad_set_id,ad_id,time_zone,'pauchase',pay_time
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_pay_record', 'appsflyer', 'SDFKKJ#%#23sf1632') WHERE pay_time is NOT NULL;


// 留存表
CREATE TABLE `appsflyer_retention` (
`data_date` Int64  COMMENT '分析时间',
`game_id` String  DEFAULT '0' COMMENT 'appid',
`platform` String  COMMENT '平台',
`media_source` String  COMMENT '媒体平台 googleadwords_int',
`campaign_id` String  COMMENT '广告系列ID 23843308705120641',
`region` String  DEFAULT 'KR' COMMENT '韩国KR, 香港 HK, 台湾 TW, 其它：-1，或者其它值',
`ad_set_id` String  DEFAULT '-1' COMMENT '广告组|计划ID 23843308705230641',
`ad_id` String  DEFAULT '-1' COMMENT '广告ID 23843308708070641',
`currency` String  COMMENT '货币类型',
`register_num` Int64  DEFAULT '0' COMMENT '注册人数',
`retention_day1` Int64  DEFAULT '0' COMMENT '1日留存',
`retention_day2` Int64  DEFAULT '0' COMMENT '2日留存',
`retention_day3` Int64  DEFAULT '0' COMMENT '3日留存',
`retention_day4` Int64  DEFAULT '0' COMMENT '4日留存',
`retention_day5` Int64  DEFAULT '0' COMMENT '5日留存',
`retention_day6` Int64  DEFAULT '0' COMMENT '6日留存',
`retention_day7` Int64  DEFAULT '0' COMMENT '7日留存',
`retention_day8` Int64  DEFAULT '0' COMMENT '8日留存',
`retention_day9` Int64  DEFAULT '0' COMMENT '9日留存',
`retention_day10` Int64  DEFAULT '0' COMMENT '10日留存',
`retention_day11` Int64  DEFAULT '0' COMMENT '11日留存',
`retention_day12` Int64  DEFAULT '0' COMMENT '12日留存',
`retention_day13` Int64  DEFAULT '0' COMMENT '13日留存',
`retention_day14` Int64  DEFAULT '0' COMMENT '14日留存',
`retention_day15` Int64  DEFAULT '0' COMMENT '15日留存',
`retention_day16` Int64  DEFAULT '0' COMMENT '16日留存',
`retention_day17` Int64  DEFAULT '0' COMMENT '17日留存',
`retention_day18` Int64  DEFAULT '0' COMMENT '18日留存',
`retention_day19` Int64  DEFAULT '0' COMMENT '19日留存',
`retention_day20` Int64  DEFAULT '0' COMMENT '20日留存',
`retention_day21` Int64  DEFAULT '0' COMMENT '21日留存',
`retention_day22` Int64  DEFAULT '0' COMMENT '22日留存',
`retention_day23` Int64  DEFAULT '0' COMMENT '23日留存',
`retention_day24` Int64  DEFAULT '0' COMMENT '24日留存',
`retention_day25` Int64  DEFAULT '0' COMMENT '25日留存',
`retention_day26` Int64  DEFAULT '0' COMMENT '26日留存',
`retention_day27` Int64  DEFAULT '0' COMMENT '27日留存',
`retention_day28` Int64  DEFAULT '0' COMMENT '28日留存',
`retention_day29` Int64  DEFAULT '0' COMMENT '29日留存',
`retention_day30` Int64  DEFAULT '0' COMMENT '30日留存',
`retention_day35` Int64  DEFAULT '0' COMMENT '35日留存',
`retention_day40` Int64  DEFAULT '0' COMMENT '40日留存',
`retention_day45` Int64  DEFAULT '0' COMMENT '45日留存',
`retention_day50` Int64  DEFAULT '0' COMMENT '50日留存',
`retention_day55` Int64  DEFAULT '0' COMMENT '55日留存',
`retention_day60` Int64  DEFAULT '0' COMMENT '60日留存',
`retention_day65` Int64  DEFAULT '0' COMMENT '65日留存',
`retention_day70` Int64  DEFAULT '0' COMMENT '70日留存',
`retention_day75` Int64  DEFAULT '0' COMMENT '75日留存',
`retention_day80` Int64  DEFAULT '0' COMMENT '80日留存',
`retention_day85` Int64  DEFAULT '0' COMMENT '85日留存',
`retention_day90` Int64  DEFAULT '0' COMMENT '90日留存',
`retention_day120` Int64  DEFAULT '0',
`retention_day150` Int64  DEFAULT '0',
`retention_day180` Int64  DEFAULT '0'
) ENGINE=SummingMergeTree
PARTITION BY intDiv(data_date , 100)
order by(`data_date`,`game_id`,`media_source`,`campaign_id`,`ad_set_id`,`ad_id`,`platform`,`currency`,`region`)
SETTINGS index_granularity = 8192


//留存迁移数据
//留存迁移数据
INSERT into appsflyer_retention
select
`ds` as data_date ,
`game_id` ,
`platform`,
`media_source` ,
`campaign_id` ,
`region`   ,
`ad_set_id`   ,
`ad_id`   ,
`currency` ,
`register_num`,
`retention_day1` ,
`retention_day2` ,
`retention_day3` ,
`retention_day4` ,
`retention_day5` ,
`retention_day6` ,
`retention_day7` ,
`retention_day8` ,
`retention_day9` ,
`retention_day10`,
`retention_day11`,
`retention_day12`,
`retention_day13`,
`retention_day14`,
`retention_day15`,
`retention_day16`,
`retention_day17`,
`retention_day18`,
`retention_day19`,
`retention_day20`,
`retention_day21`,
`retention_day22`,
`retention_day23`,
`retention_day24`,
`retention_day25`,
`retention_day26`,
`retention_day27`,
`retention_day28`,
`retention_day29`,
`retention_day30`,
`retention_day35`,
`retention_day40`,
`retention_day45`,
`retention_day50`,
`retention_day55`,
`retention_day60`,
`retention_day65`,
`retention_day70`,
`retention_day75`,
`retention_day80`,
`retention_day85`,
`retention_day90`,
`retention_day120`,
`retention_day150`,
`retention_day180`
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_order_accumulative', 'appsflyer', 'SDFKKJ#%#23sf1632')




//事件表
CREATE TABLE adv_appsflyer.appsflyer_event_times
(

    `data_date` Int32 COMMENT '激活日期',

    `region` String DEFAULT 'KR' COMMENT '地区',

    `media_source` String COMMENT '媒体',

    `platform` String COMMENT '平台 Android|IOS',

    `game_id` String COMMENT '游戏ID bundle_id,
com.edgames.new19gp',

    `campaign_id` String COMMENT '广告系列ID 23843308705120641',

    `event_name` String,

    `event_date` Int32,
	
    `times` Int64 COMMENT '发生次数'

)
ENGINE=SummingMergeTree
PARTITION BY intDiv(data_date , 100)
order by(`data_date`,`region`,`media_source`,`platform`,`game_id`,`campaign_id`,`event_name`,`event_date`)
SETTINGS index_granularity = 8192

//事件表导数据
INSERT into appsflyer_event_times
select `data_date`,`region`,`media_source`,`platform`,`game_id`,`campaign_id`,`event_name`,`event_date`,`times`
FROM mysql('172.17.16.32:3306', 'adv_appsflyer_new_sheteng', 'appsflyer_event_times', 'appsflyer', 'SDFKKJ#%#23sf1632')












//mysqlshuju
<!-- media -->
CREATE TABLE media(`id` Int32,`af_media_id` String,`name` String ,`permission_id` Int32,`type` Int8,`last_update_time` DateTime) engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'media', 'appsflyer', 'Hs*9Ds1&s');

<!-- adgroup_media_mapping -->
CREATE TABLE adgroup_media_mapping (
`id` Int32,
`media_id` Int32,
`af_media_id` String,
`af_group_id` String,
`af_group_name` String,
`user_id` Int32,
`user_name` String,
`permission_id` Int32
)engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'adgroup_media_mapping', 'appsflyer', 'Hs*9Ds1&s');

<!-- appsflyer_event_name -->
CREATE TABLE appsflyer_event_name (
`id` Int32,
`af_app_id` Nullable(String),
`af_event_id` Nullable(String),
`af_event_name` Nullable(String)
) engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'appsflyer_event_name', 'appsflyer', 'Hs*9Ds1&s');



CREATE TABLE game (
`id` Int16 ,
`platform_id` Int16 ,
`af_app_id` String ,
`af_app_name` String ,
`time_zone` String DEFAULT '+0900' COMMENT '时区',
`select_time_zone` String ,
`permission_id` Int32 ,
`last_update_time` DateTime COMMENT '最后更新时间',
`app_id` String  COMMENT 'app_id 用于数据同步',
`currency` String DEFAULT 'KRW',
`rate` Float32 DEFAULT '0.00089',
`state` Int8 DEFAULT '1',
`cost_currency` String DEFAULT 'KRW',
`cost_rate` Float32 DEFAULT '0.00089'
) engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'game', 'appsflyer', 'Hs*9Ds1&s');


CREATE TABLE game_events_relationship (
`id` Int32 ,
`user_id` Int32 ,
`platform` String  DEFAULT 'android',
`af_app_id` String ,
`group_id` Int32 ,
`group_name` String ,
`events` String
) engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'game_events_relationship', 'appsflyer', 'Hs*9Ds1&s');


CREATE TABLE game_media_relationship (
`id` Int32 ,
`platform_id` Int32 ,
`platform` String ,
`game_id` Int32 ,
`game` String ,
`media_id` Int32 ,
`media` String ,
`media_name` String
) engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'game_media_relationship', 'appsflyer', 'Hs*9Ds1&s');


CREATE TABLE `user_auto_permission` (
`id` Int32 ,
`user_id` Int32,
`auto_game` Int32 ,
`auto_platform` String,
`created_at` DateTime,
`updated_at` DateTime,
`auto_platform_games` String)engine= MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'user_auto_permission', 'appsflyer', 'Hs*9Ds1&s');



    CREATE TABLE `user_game_media` (
`id` Int32,
`user_id` Int32,
`platform` String COMMENT '平台',
`game_id` String COMMENT '游戏',
`media_source` String COMMENT '媒体'
) ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'user_game_media', 'appsflyer', 'Hs*9Ds1&s');


CREATE TABLE `user_media_campign` (
`id` Int32,
`user_id` Int32,
`principal_user_id` Int32,
`principal_user_name` Int32,
`auth_af_media_id` String,
`auth_af_ad_group_id` String
)ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'user_media_campign', 'appsflyer', 'Hs*9Ds1&s');

CREATE TABLE `user_shield_columns` (
`id` Int32,
`uid` Int32,
`name` String DEFAULT '' COMMENT '列组合名称',
`menu` String DEFAULT '' COMMENT '菜单栏',
`column` String COMMENT '自定义列',
`is_use` Int8 COMMENT '默认使用'
) ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'user_shield_columns', 'appsflyer', 'Hs*9Ds1&s');


CREATE TABLE `users` (
`id` Int32,
`username` String,
`password` String,
`realName` String,
`status` Int8,
`permission` String,
`token` String,
`is_wechat` Int32,
`created_at` DateTime,
`updated_at` DateTime
)ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'users', 'appsflyer', 'Hs*9Ds1&s');

CREATE TABLE `appsflyer_pay_record_server` (
`id` Int32 ,
`did` String  DEFAULT '-1',
`uid` String  COMMENT '用户ID, appsflyer_device_id',
`game_id` String  COMMENT '游戏ID bundle_id com.edgames.new19gp',
`platform` String  COMMENT '平台 Android|IOS',
`media_source` String  COMMENT '媒体平台 googleadwords_int',
`campaign_id` String  COMMENT '广告系列ID 23843308705120641',
`ad_set_id` String  DEFAULT '-1' COMMENT '广告组|计划ID 23843308705230641',
`ad_id` String  DEFAULT '-1' COMMENT '广告ID 23843308708070641',
`channel` String  COMMENT 'channel',
`pay_time` DateTime  COMMENT '支付时间 2019-02-28 00:07:06',
`money` Float64  COMMENT '支付金额',
`region` String  DEFAULT 'KR' COMMENT '韩国KR, 香港 HK, 台湾 TW, 其它：-1，或者其它值',
`currency` String  DEFAULT 'KRW' COMMENT '货币类型',
`order_no` String  COMMENT '订单编号',
`time_zone` String DEFAULT '+0900' COMMENT '时区',
`server_reg_date` Int32  COMMENT '区服注册时间',
`server_reg_hour` Int32  COMMENT '区服注册的小时数',
`reg_server_id` String  COMMENT '区服id'
) ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'appsflyer_pay_record_server', 'appsflyer', 'Hs*9Ds1&s');


CREATE TABLE `appsflyer_metrics_server` (
`data_date` Int64  COMMENT '日期 20190228',
`data_hour` Int64  COMMENT '小时 13',
`time_zone` String  COMMENT '时区 +0900',
`media_source` String  COMMENT '媒体平台 googleadwords_int',
`platform` String  COMMENT '平台 Android|IOS',
`game_id` String  COMMENT '游戏ID bundle_id, com.edgames.new19gp',
`campaign_id` String  COMMENT '广告系列ID 23843308705120641',
`ad_set_id` String  COMMENT '广告组|计划ID 23843308705230641',
`ad_id` String  COMMENT '广告ID 23843308708070641',
`region` String  DEFAULT 'KR' COMMENT '韩国KR, 香港 HK, 台湾 TW, 其它：-1，或者其它值',
`channel` String  DEFAULT '-1',
`server_id` String  DEFAULT '-1',
`data_view` Int64 DEFAULT '0' COMMENT '展示数(impression) 按唯一设备去重',
`data_click` Int64 DEFAULT '0' COMMENT '点击数(clicks) 按唯一设备去重',
`data_activation` Int64 DEFAULT '0' COMMENT '激活数 按唯一设备去重 ',
`data_register` Int64 DEFAULT '0' COMMENT '注册数 按唯一用户去重',
`data_day_act_register` Int64  DEFAULT '0' COMMENT '当日激活 并且当日注册数',
`data_device_register` Int64  DEFAULT '0' COMMENT '设备注册数',
`data_create_role` Int64 DEFAULT '0' COMMENT '创角数',
`data_day_register_create` Int64  DEFAULT '0' COMMENT '当日注册 并且当日创角数',
`data_active_day_dau` Int64 DEFAULT '0' COMMENT '当日登录用户，排除当日注册用户',
`data_active_2day` Int64 DEFAULT '0' COMMENT '次日活跃|留存',
`data_active_3day` Int64 DEFAULT '0' COMMENT '3日活跃|留存',
`data_active_7day` Int64 DEFAULT '0' COMMENT '7日活跃|留存',
`data_active_15day` Int64 DEFAULT '0' COMMENT '15日活跃|留存',
`data_active_30day` Int64 DEFAULT '0' COMMENT '30日活跃|留存'
)ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'appsflyer_metrics_server', 'appsflyer', 'Hs*9Ds1&s');




INSERT INTO appsflyer_cost (data_date , region ,media_source ,platform ,game_id ,campaign_id ,ad_set_id ,ad_id ,channel ,cost,data_click,data_view,channel_click,channel_view)
select data_date , region ,media_source ,platform ,game_id ,campaign_id ,ad_set_id ,ad_id ,channel ,0,SUM(data_click) as data_click
,SUM(data_view) as data_view ,sum(channel_click) as channel_click ,SUM(channel_view) as channel_view from appsflyer_metrics
WHERE data_click > 0 or data_view > 0 or channel_click  > 0 or channel_view  > 0
GROUP BY data_date , region ,media_source ,platform ,game_id ,campaign_id ,ad_set_id ,ad_id ,channel
on duplicate key UPDATE data_click= VALUES(data_click) ,data_view = VALUES(data_view ), channel_click = VALUES (channel_click ) ,channel_view  = VALUES(channel_view)



CREATE TABLE `appsflyer_cost` (
`data_date` Int32  COMMENT '日期',
`region` String  DEFAULT 'KR' COMMENT '地区',
`media_source` String  COMMENT '媒体',
`platform` String  COMMENT '平台 Android|IOS',
`game_id` String  COMMENT '游戏ID bundle_id, com.edgames.new19gp',
`campaign_id` String  COMMENT '广告系列ID 23843308705120641',
`ad_set_id` String  COMMENT '广告组|计划ID 23843308705230641',
`ad_id` String  COMMENT '广告ID 23843308708070641',
`cost` Float64  COMMENT '成本',
`last_update_time` DateTime  COMMENT '最后更新时间',
`op_uid` Int32  COMMENT '导入用户id ',
`channel` String  DEFAULT '-1',
`priority` Int32  DEFAULT '3' COMMENT '优先级:1后台操作,2实时拉取,3AF获取',
`data_view` Int64 ,
`data_click` Int64 ,
`channel_view` Int64 ,
`channel_click` Int64
) ENGINE=MySQL('172.17.16.16:3306', 'adv_appsflyer_new', 'appsflyer_cost', 'appsflyer', 'Hs*9Ds1&s');
