使用Talend Open Studio將資料從oracle匯入到hive中

來源:互聯網
上載者:User

標籤:

先使用Tos建立模型,將Oracle中的資料匯入到本地:

build job後,形成獨立可以啟動並執行程式:

將產生的zip檔案,上傳到hadoop叢集上,有hive環境的機器上:

[[email protected] work]$ lsfile.zip  jobInfo.properties  join  lib[[email protected] work]$ cd join/[[email protected] join]$ lsbigdatademo  items  join_0_1.jar  join_run.bat  join_run.sh  src  user_activity2[[email protected] join]$ pwd/home/work/join[[email protected] join]$ lsbigdatademo  items  join_0_1.jar  join_run.bat  join_run.sh  src  user_activity2[[email protected] join]$ pwd/home/work/join[[email protected] join]$ ./join_run.sh > user_activity2 2>&1 &

這樣就得到了SQL語句執行的結果,存放在user_activity2中。

hive建表語句:

 

hive> show create table user_activity2;OKCREATE TABLE `user_activity2`(  `user_id` string,   `user_name` string,   `sex` string,   `age` string,   `reg_hosp` string,   `reg_community` string,   `type` string,   `disease_code` string,   `disease` string,   `doctor` string,   `hosp_name` string,   `service_id` string,   `drug_id` string,   `drug_name` string,   `antibiotic` string,   `hormone` string,   `source` string,   `base_drug` string,   `community` string,   `date` string)ROW FORMAT DELIMITED   FIELDS TERMINATED BY ‘|‘ STORED AS INPUTFORMAT   ‘org.apache.hadoop.mapred.TextInputFormat‘ OUTPUTFORMAT   ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat‘LOCATION  ‘hdfs://h1:8020/apps/hive/warehouse/cyw.db/user_activity2‘TBLPROPERTIES (  ‘transient_lastDdlTime‘=‘1435547544‘)Time taken: 0.288 seconds, Fetched: 31 row(s)

將資料匯入到hive表中:load data local inpath ‘./user_activity2‘ into table user_activity2;

hive> show tables;                                                         OKTime taken: 0.794 secondshive> use cyw;OKTime taken: 0.256 secondshive> show tables;OKuser_activityuser_activity2Time taken: 0.136 seconds, Fetched: 2 row(s)hive> load data local inpath ‘./user_activity2‘ into table  user_activity2;Loading data to table cyw.user_activity2Table cyw.user_activity2 stats: [numFiles=1, totalSize=216927483]OKTime taken: 10.898 secondshive> select * from user_activity2;OKF805418B-335F-4CA3-A209-7C9655148146    餘澤英  2       47      成都高新區合作社區衛生服務中心  合作    1               急性支氣管炎    譚萬龍  成都高新區合作社區衛生服務中心  1E972231-C65A-4CE3-9233-8EA1B18058DE  滅菌注射用水    d875aacf-4723-4777-91ec-12d63732b58f    0       0       其他            合作    2014-02-27F805418B-335F-4CA3-A209-7C9655148146    餘澤英  2       47      成都高新區合作社區衛生服務中心  合作

查詢語句:

select a.個人id,       b.姓名,       b.性別,       round((sysdate - b.出生日期) / 365) as fage,       b.建檔單位,       replace(replace(replace(b.建檔單位, ‘高新區‘), ‘社區衛生服務中心‘),               ‘成都‘) 建檔社區,       1 as ftype,       a.問題編碼,       a.問題名稱,       a.處理醫生,       c.機構名,       a.服務記錄id,       f.名稱,       f.id 藥品ID ,       f.抗生素,        f.激素類藥,       case when f.藥品來源 is null then ‘其他‘ else f.藥品來源 end 藥品來源,              f.基藥分類,       replace(replace(replace(c.機構名, ‘高新區‘), ‘社區衛生服務中心‘),‘成都‘) 診療社區,        to_char(a.發現日期, ‘yyyy-mm-dd‘) 診療日期  from ZLCHS.個人問題列表 a,       ZLCHS.個人資訊 b,       ZLCHS.服務活動記錄 c,       (select d.事件id, e.名稱, e.id, h.藥品來源, h.基藥分類, g.抗生素, g.激素類藥          from ZLCHS.個人費用記錄 d, ZLCHS.收費項目目錄 e, ZLCHS.藥品規格 h, ZLCHS.藥品特性 g         where d.收費項目id = e.id           and d.收據費目 in (‘西藥費‘, ‘中草藥費‘, ‘中成藥費‘)           and h.藥品id(+) = e.id           and h.藥名id = g.藥名id) f                  where a.個人id = b.id(+)   and a.服務記錄id = c.id(+)   and a.服務記錄id = f.事件id(+)

 

 

 

 

 

 

使用Talend Open Studio將資料從oracle匯入到hive中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.