0: jdbc:hive2://t1:10000> INSERT INTO TABLE ADS_APL_NRT_DEMO............>SELECT............> first_dt as dt,............>count(1)as dnu_cnts,............> datediff('2020-01-16',first_dt)as nrt_days,............>count(if(last_dt='2020-01-16',1,null))as nrt_users
............>FROM DEMO_DWS_APL_HSU_REC
............>GROUPBY first_dt
............>;
Error: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: FAILED: Execution Error,return code 2from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
at org.apache.hive.service.cli.operation.Operation.toSQLException(Operation.java:380)
at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:257)
at org.apache.hive.service.cli.operation.SQLOperation.access$800(SQLOperation.java:91)
at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1844)
at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:362)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)(state=08S01,code=2)
尝试解决方案一 发现正如网上所说 使用的数据有一列(last_dt)为null 修正后未恢复正常
select*from DEMO_DWS_APL_HSU;+----------------------+------------------------+----------------------------+---------------------------+| demo_dws_apl_hsu.dt | demo_dws_apl_hsu.guid | demo_dws_apl_hsu.first_dt | demo_dws_apl_hsu.last_dt |+----------------------+------------------------+----------------------------+---------------------------+| a |2020-01-12|2020-01-16|NULL|| b |2020-01-12|2020-01-15|NULL|| c |2020-01-12|2020-01-16|NULL|| d |2020-01-12|2020-01-13|NULL|| e |2020-01-12|2020-01-16|NULL|| f |2020-01-12|2020-01-16|NULL|| g |2020-01-13|2020-01-14|NULL|| h |2020-01-13|2020-01-15|NULL|| j |2020-01-13|2020-01-16|NULL|| k |2020-01-13|2020-01-14|NULL|| m |2020-01-13|2020-01-15|NULL|| n |2020-01-13|2020-01-14|NULL|| o |2020-01-14|2020-01-16|NULL|| p |2020-01-14|2020-01-14|NULL|| q |2020-01-14|2020-01-14|NULL|| r |2020-01-14|2020-01-16|NULL|| s |2020-01-14|2020-01-16|NULL|| t |2020-01-15|2020-01-15|NULL|| u |2020-01-15|2020-01-16|NULL|| v |2020-01-15|2020-01-16|NULL|+----------------------+------------------------+----------------------------+---------------------------+
Norows selected (0.184 seconds)0: jdbc:hive2://localhost:10000> INSERT INTO TABLE ADS_APL_NRT_DEMO................>SELECT................> first_dt as dt,................>count(1)as dnu_cnts,................> datediff('2020-01-16',first_dt)as nrt_days,................>count(if(last_dt='2020-01-16',1,null))as nrt_users
................>FROM DEMO_DWS_APL_HSU_REC
................>GROUPBY first_dt
................>;
WARNING: Hive-on-MR is deprecated in Hive 2and may not be available in the future versions. Consider using a different execution engine(i.e. spark, tez)orusing Hive 1.X releases.Norows affected (2.761 seconds)0: jdbc:hive2://localhost:10000>