为什么Pig不接受将整数转换为chararray

时间:2019-09-09 13:30:53

标签: apache-pig

我有这个猪脚本:

CRE_22002 = LOAD '$input' USING  PigStorage(';') AS (GM_COMPTEUR:chararray,CIA_CD_CRV_CIA:chararray,CIA_DA_EM_CRV:chararray,CIA_CD_CTRL_BLCE:chararray,CIA_IDC_EXTR_RDJ:chararray,CIA_VLR_IDT_CRV_LOQ:chararray,CIA_VLR_REF_CRV:chararray,CIA_NO_SEQ_CRV:chararray,CIA_VLR_LG_ZON_RTG:chararray,CIA_HEU_CIA:chararray,CIA_TM_STP_CRE:chararray,CIA_CD_SI:chararray,CIA_VLR_1:chararray,CIA_DA_ARR_FIC:chararray,CIA_TY_ENR:chararray,CIA_CD_BTE:chararray,CIA_CD_PER:chararray,CIA_CD_EFS:chararray,CIA_CD_ETA_VAL_CRV:chararray,CIA_CD_EVE_CPR:chararray,CIA_CD_APLI_TDU:chararray,CIA_CD_STE_RTG:chararray,CIA_DA_TT_RTG:chararray,CIA_NO_ENR_RTG:chararray,CIA_DA_VAL_EVE:chararray,PSE_001:chararray,STR_002:chararray,STR_003:chararray,CPR_006_VLR:chararray,CPR_006_DCM:chararray,CPR_006_CD_DVS:chararray,CPR_008_VLR:chararray,CPR_008_DCM:chararray,CPR_008_CD_DVS:chararray,CPR_009_VLR:chararray,   CPR_009_DCM:chararray,CPR_009_CD_DVS:chararray,CPR_059_VLR:chararray,CPR_059_DCM:chararray,CPR_059_CD_DVS:chararray,CPR_060_VLR:chararray,CPR_060_DCM:chararray,CPR_060_CD_DVS:chararray,RUB_205:chararray,RUB_216:chararray,DAT_015_X:chararray,NB_005_VLR:chararray,NB_005_DCM:chararray,NB_007_VLR:chararray,NB_007_DCM:chararray,NB_012_VLR:chararray,NB_012_DCM:chararray,EUR_061_VLR:chararray,EUR_061_DCM:chararray,EUR_061_CD_DVS:chararray,EUR_062_VLR:chararray,EUR_062_DCM:chararray,EUR_062_CD_DVS:chararray);

-生成列

CRE_22002_DATA = FOREACH CRE_22002 GENERATE

(chararray) (   $0  )   AS  MGM_COMPTEUR,   
(chararray) (   $1  )   AS  CIA_CD_CRV_CIA, 
(chararray) (   $2  )   AS  CIA_DA_EM_CRV,  
(chararray) (   $3  )   AS  CIA_CD_CTRL_BLCE,   
(chararray) (   $4  )   AS  CIA_IDC_EXTR_RDJ,   
(chararray) (   $5  )   AS  CIA_VLR_IDT_CRV_LOQ,    
(chararray) (   $6  )   AS  CIA_VLR_REF_CRV,    
(chararray) (   $7  )   AS  CIA_NO_SEQ_CRV, 
(chararray) (   $8  )   AS  CIA_VLR_LG_ZON_RTG, 
(chararray) (   $9  )   AS  CIA_HEU_CIA,    
(chararray) (   $10 )   AS  CIA_TM_STP_CRE, 
(chararray) (   $11 )   AS  CIA_CD_SI,  
(chararray) (   $12 )   AS  CIA_VLR_1,  
(chararray) (   $13 )   AS  CIA_DA_ARR_FIC, 
(chararray) (   $14 )   AS  CIA_TY_ENR, 
(chararray) (   $15 )   AS  CIA_CD_PER, 
(chararray) (   $16 )   AS  CIA_CD_EFS, 
(chararray) (   $17 )   AS  CIA_CD_ETA_VAL_CRV, 
(chararray) (   $18 )   AS  CIA_CD_EVE_CPR, 
(chararray) (   $19 )   AS  CIA_CD_APLI_TDU,    
(chararray) (   $20 )   AS  CIA_CD_STE_RTG, 
(chararray) (   $21 )   AS  CIA_DA_TT_RTG,  
(chararray) (   $22 )   AS  CIA_NO_ENR_RTG, 
(chararray) (   $23 )   AS  CIA_DA_VAL_EVE, 
(chararray) (   $24 )   AS  PSE_001,    
(chararray) (   $25 )   AS  STR_002,    
(chararray) (   $26 )   AS  STR_003,    
(chararray) (   $27 )   AS  CPR_006_VLR,    
(chararray) (   $28 )   AS  CPR_006_DCM,    
(chararray) (   $29 )   AS  CPR_006_CD_DVS, 
(chararray) (   $30 )   AS  CPR_008_VLR,    
(chararray) (   $31 )   AS  CPR_008_DCM,    
(chararray) (   $32 )   AS  CPR_008_CD_DVS, 
(chararray) (   $33 )   AS  CPR_009_VLR,    
(chararray) (   $34 )   AS  CPR_009_DCM,    
(chararray) (   $35 )   AS  CPR_009_CD_DVS, 
(chararray) (   $36 )   AS  CPR_059_VLR,    
(chararray) (   $37 )   AS  CPR_059_DCM,    
(chararray) (   $38 )   AS  CPR_059_CD_DVS, 
(chararray) (   $39 )   AS  CPR_060_VLR,    
(chararray) (   $40 )   AS  CPR_060_DCM,    
(chararray) (   $41 )   AS  CPR_060_CD_DVS, 
(chararray) (   $42 )   AS  RUB_205,    
(chararray) (   $43      )  AS     RUB_216, 
(chararray) ($44)              AS   DAT_015_X,  
(chararray) (   $45 )   AS  NB_005_VLR, 
(chararray) (   $46 )   AS  NB_005_DCM, 
(chararray) (   $47 )   AS  NB_007_VLR, 
(chararray) (   $48 )   AS  NB_007_DCM, 
(chararray) (   $49 )   AS  NB_012_VLR, 
(chararray) (   $50 )   AS  NB_012_DCM, 
(chararray) (   $51 )   AS  EUR_061_VLR,    
(chararray) (   $52 )   AS  EUR_061_DCM,    
(chararray) (   $53 )   AS  EUR_061_CD_DVS, 
(chararray) (   $54 )   AS  EUR_062_VLR,    
(chararray) (   $55 )   AS  EUR_062_DCM,    
(chararray) (   $56 )   AS  EUR_062_CD_DVS; 

-Sauvegarder le resultat

CRE_22002_DATA_FILTER = FILTER CRE_22002_DATA  BY (ToDate(DAT_015_X,'yyyyMMdd')> ToDate('20190101','yyyyMMdd')); 

-商店

STORE CRE_22002_DATA_FILTER  INTO '/hdfs/data/adhoc/PR/02/RDO0/BB0/MGM22002-OUTPUT.csv' USING org.apache.pig.piggybank.storage.CSVExcelStorage(';','NO_MULTILINE', 'UNIX','WRITE_OUTPUT_HEADER'); 

我知道RUB_216列包含整数,但由espace给出: 就像:

;16 ;
;17 ;
..

所以我决定将其转换为chararray。

运行Pig脚本时:

  

错误0:执行时发生异常(名称:CRE_22002_DATA:新建   每个(false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false, false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false, false,false,false,false,false,false,false,false)[袋]   -scope-353操作员密钥:scope-353):org.apache.pig.backend.executionengine.ExecException:错误0:   执行[POUserFunc(名称:   POUserFunc(org.apache.pig.builtin.ToDate2ARGS)[datetime]-范围179   操作员密钥:scope-179)子元素:[[]]为空:   java.lang.IllegalArgumentException:格式无效:“ RUB_216”

请帮忙吗?

0 个答案:

没有答案