2016-03-21 16 views
0

Ben domuz 0.15 kullanıyorum, aşağıdaki gibi ORC biçiminde dosya saklanır. kovanlık ile başarısız oldu java.io.IOException: java.lang.ClassCastException: java.sql.Timestamp java.sql.Date için kullanılamaz.

loading_data= Load '/user/location/emp.csv' using PigStorage('\u241C') AS (
empno:long 
,ename:chararray 
,job:chararray 
,mgr:float 
,hiredate:chararray 
,sal:bigdecimal 
,comm:bigdecimal 
,deptno:int 
,flag:chararray 
); 

processed_data = FOREACH loading_data GENERATE 
empno 
,ename 
,job 
,mgr 
,ToDate(hiredate,'MM/dd/yyyy HH:mm') as (hiredate:datetime) 
,sal 
,comm 
,deptno 
,flag; 



store processed_data into '/user/myfolder/newLocation' using OrcStorage(); 

Şimdi
CREATE EXTERNAL Table emp123(
    empno BIGINT, 
    ename STRING, 
    job  String, 
    mgr  FLOAT, 
    hiredate DATE, 
    sal  DECIMAL(15,2), 
    comm  DECIMAL(10,2), 
    deptno int, 
    flag  String 
) 
comment 'EMP test table' 
stored as ORC 
location '/user/myfolder/newLocation/' 

Şimdi bir hata alırsınız sorguda altına he çalıştırmak isteyebilirsiniz aşağıda gibi HIVE tablo oluşturma. koray> emp123'ten * seçin *; Tamam

istisna java.io.IOException ile başarısız oldu: java.lang.ClassCastException: java.sql.Timestamp alınan java.sql.Date Saati'ne döküm edilemez: 1,478 saniye

Herhangi bir öneri lütfen.

cevap

0

HIVE tablosu tanımlaması için tarih yerine zaman damgasını kullanın. PigScript öğesinin, hireddate sütunu için zaman kısmı vardır. Tarihi Tarih türleri, gün bileşeni içermez.

CREATE EXTERNAL Table emp123(
       empno BIGINT, 
       ename STRING, 
       job  String, 
       mgr  FLOAT, 
       hiredate timestamp, 
       sal  DECIMAL(15,2), 
       comm  DECIMAL(10,2), 
       deptno int, 
       flag  String 
) 
comment 'EMP test table' 
stored as ORC 
location '/user/myfolder/newLocation/' 
İlgili konular