hadoop - PIG - matching toDate function -
i trying cast string datetime object in hadoop pig. grunt give me strange error message : can't choose correct 'todate' function. asking 'explicit cast', have no clue how so. idea ?
=> error 1045: not infer matching function org.apache.pig.builtin.todate multiple or none of them fit. please use explicit cast.
grunt> describe infos_by_nu_affa; infos_by_nu_affa: {nu_affa: bytearray,affaires: {(nu_affa:bytearray,nu_pcp: bytearray,debut: bytearray,fin: bytearray)},prestations: {(nu_affa: bytearray,montant: bytearray,date: bytearray,nu_presta: bytearray,beneficiaire: bytearray)},clients: {(nu_pcp: bytearray,nom: bytearray,prenom: bytearray)}} derivees = foreach infos_by_nu_affa generate *, todate(affaires.debut, 'dd/mm/yyyy') (debut:datetime); 2015-03-28 15:46:36,089 [main] error org.apache.pig.tools.grunt.grunt - error 1045: <line 155, column 0> not infer matching function org.apache.pig.builtin.todate multiple or none of them fit. please use explicit cast. grunt> dump infos_by_nu_affa (affaire5,{(affaire5,client5,01/01/14,05/01/15)},{},{(client5,enders,kililan)}) (affaire6,{(affaire6,client6,01/01/13,01/06/14)},{},{(client6,blanco,martine)}) (affaire7,{(affaire7,client7,01/01/10,02/03/13)},{},{(client7,sarah,moore)}) (affaire8,{(affaire8,client8,01/01/15,01/01/01)},{},{(client8,evrard,dominique)}) grunt> derivees = foreach infos_by_nu_affa >> generate *, >> count(prestations) nb_prestations, >> todate(affaires.debut, 'dd/mm/yy') debut; 2015-03-28 15:56:06,729 [main] error org.apache.pig.tools.grunt.grunt - error 1045: <line 155, column 0> not infer matching function org.apache.pig.builtin.todate multiple or none of them fit. please use explicit cast.
the reason passing bag datatype(ie,affaires.debut)
input todate
function todate
function accept chararray or byterarray
input. solve issue, need flatten
(affaires.debut)
before passing todate
function. should this
derivees_temp = foreach infos_by_nu_affa generate *,flatten(affaires.debut) (debut_temp:chararray); derivees = foreach derivees_temp generate *, todate(debut_temp, 'dd/mm/yyyy') (debut:datetime);
note: in first stmt(ie,derivees_temp
), after flattening datatype debut_temp
chararray
, second stmt(ie, derivees
) after todate
datatype debut
datetime
.
Comments
Post a Comment