濡傛灉鏁版嵁搴撶被鍨嬫槸 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 濂藉儚.
聽