sql(1) : 整合数据

1.读表

Create table if not exists part1 as select * from odps_tc_257100_f673506e024.meinian_round2_data_part1;
Create table if not exists part2 as select * from odps_tc_257100_f673506e024.meinian_round2_data_part2;
Create table if not exists snp as select * from odps_tc_257100_f673506e024.meinian_round2_SNP;

2.

select cast(user_id as double) as new_id from user;
select cast('2015-10-01 00:00:00' as datetime) as new_date from user;

-输入数据已自动映射成t1~t4,使用方式如:select * from ${t1}
--用户也可以直接输入ODPS表使用。
--本组件支持ODPS SQL的所有语法,最后一条SQL必须为select语句,查询结果作为本组件的输出数据

select age,
(case sex when 'male' then 1 else 0 end) as sex,
(case cp when 'angina' then 0  when 'notang' then 1 else 2 end) as cp,
trestbps,
chol,
(case fbs when 'true' then 1 else 0 end) as fbs,
(case restecg when 'norm' then 0  when 'abn' then 1 else 2 end) as restecg,
thalach,
(case exang when 'true' then 1 else 0 end) as exang,
oldpeak,
(case slop when 'up' then 0  when 'flat' then 1 else 2 end) as slop,
ca,
(case thal when 'norm' then 0  when 'fix' then 1 else 2 end) as thal,
(case status  when 'sick' then 1 else 0 end) as ifHealth
from  ${t1};

猜你喜欢

转载自blog.csdn.net/yao_tc/article/details/80289914