Error: Error while compiling statement: FAILED: ParseException line 11:5 missing KW_END at 'substr' near 'substr'
line 11:11 missing EOF at '(' near 'substr'(state=42000,code=40000)
sql如下:
createtable szdsjsxm_sj.xxx_10000453_jieguo
ROW FORMAT DELIMITED FIELDSTERMINATEDBY'|' STORED AS TEXTFILE
TBLPROPERTIES ('serialization.null.format'='','serialization.encoding'='GBK')asselectdistinct
a.xuhao
,a.is_sz
,casewhen a.id= c.id_nbr then'是'when substr(a.id,1,12)= substr(c.id_nbr,1,12)then'是'when substr(a.id,1,length(a.id)-6)= substr(c.id_nbr,1,length(c.id_nbr)-6)then'是'
substr(a.id,1,length(a.id)-8)= substr(c.id_nbr,1,length(c.id_nbr)-8)and substr(a.id,-4)= substr(c.id_nbr,-4)then'是'else'否'endfrom szdsjsxm_sj.xxx_10000453_01 a
leftjoin szdsjsxm_sj.TW_PERS_LST_CUST_SZ c on c.month=202007and c.day=20200712and a.cust_id=c.cust_id
;
解决:根据报错,定位到第11行第五列,少一个when语句: 代码如下:
createtable szdsjsxm_sj.xxx_10000453_jieguo
ROW FORMAT DELIMITED FIELDSTERMINATEDBY'|' STORED AS TEXTFILE
TBLPROPERTIES ('serialization.null.format'='','serialization.encoding'='GBK')asselectdistinct
a.xuhao
,a.is_sz
,casewhen a.id= c.id_nbr then'是'when substr(a.id,1,12)= substr(c.id_nbr,1,12)then'是'when substr(a.id,1,length(a.id)-6)= substr(c.id_nbr,1,length(c.id_nbr)-6)then'是'when substr(a.id,1,length(a.id)-8)= substr(c.id_nbr,1,length(c.id_nbr)-8)and substr(a.id,-4)= substr(c.id_nbr,-4)then'是'else'否'endfrom szdsjsxm_sj.xxx_10000453_01 a
leftjoin szdsjsxm_sj.TW_PERS_LST_CUST_SZ c on c.month=202007and c.day=20200712and a.cust_id=c.cust_id
;