日期:2014-05-16  浏览次数:20456 次

sqoop 1.4.4 浣跨敤2

濡傛灉鏁版嵁搴撶被鍨嬫槸 date绫诲瀷鐨勫氨姣旇緝楹荤儲浜嗭紝鐩存帴鎼炶繘hive 涓嶈锛屽洜涓篽ive鍙湁timestamp锛岃€屽幓format杩樻槸聽聽yyyy-mm-dd hh:mm:ss鐨?/p>

鏈?涓姙娉曪紝鍏堝鍏ヤ复鏃惰〃 锛屼复鏃惰〃鏄痵tring鐨勭被鍨嬶紙String鐨刦ormat鏄?span style="font-family: monospace; font-size: 1em; line-height: 1.5;">yyyy-mm-dd锛夛紝鐒跺悗鍐嶅線姝e紡琛ㄩ噷鎻?/span>

insert overwrite table adventureworksdw.dimdate
select * from adventureworksdw.dimdate2;

鎴戜娇鐢ㄧ浜岀鍔炴硶锛宷uery 瀵煎叆

import 
--connect 
jdbc:mysql://prchaz02823:3306/adventureworksdw2008r2 
--username 
root   
--password  
root 
#--table  
#DimDate2  
--query
	'SELECT  DateKey,cast(FullDateAlternateKey as datetime) FullDateAlternateKey ,DayNumberOfWeek,EnglishDayNameOfWeek,DayNumberOfMonth,DayNumberOfYear,WeekNumberOfYear,EnglishMonthName,monthNumberOfYear,CalendarQuarter,CalendarYear ,CalendarSemester,FiscalQuarter,FiscalYear,FiscalSemester  frOM DimDate2 WHERE $CONDITIONS'
--split-by
DateKey
--null-string 
'\\N' 
--null-non-string 
'\\N'
--split-by  
DateKey 
--target-dir 
/home/dimdate_txt
--hive-import 
--hive-table 
adventureworksdw.dimdate2   
--map-column-hive
FullDateAlternateKey=timestamp
--hive-overwrite 
#--direct 

聽鎶?date绫诲瀷鐨?span style="font-family: monospace; font-size: 1em; line-height: 1.5;">FullDateAlternateKey 寮哄埗杞崲鎴恉atetime锛堜富瑕佹槸涓轰簡yyyy-mm-dd hh:mm:ss杩欎釜format锛夛紝 鐒跺悗鎸囧畾--split-by聽

杩欐牱鍦╤ive 涓氨涓嶉渶瑕佷腑闂磋〃浜?/span>

鎴戣繖閲屼娇鐢ㄧ殑涓棿鐩綍锛?/span>

--target-dir 
/home/dimdate_txt

鍚﹀垯浼氳窇鍒伴粯璁ょ殑鐩綍鍘伙紝杩欎釜鐩綍鑲畾鏄細鐢熸垚鐨勩€?/span>

鍦ㄤ綘璺戜笅涓€娆$殑鏃跺€欙紝浼氭姤閿欒鐩綍宸茬粡瀛樺湪锛屽彲浠ユ湁2绉嶅姙娉?涓€鏄垹鎺夌洰褰曪紝浜屾槸浣跨敤append 濂藉儚.