title: Hive Runtime Error while processing row in Hive [ClassCastException]
body: <p>trying to run hive query, getting hive exception. pasted the query below. I think this problem due to dirty data(column of dim_id) or formatted of data, I am  new to Hive and I don't how to deal this!
  I need your help!</p>
  
  <p>this is fdm.fdm_szad_t_exp_dim_day schema:</p>
  
  <pre><code>CREATE EXTERNAL TABLE `fdm.fdm_szad_t_exp_dim_day`(
    `mediatype` int COMMENT '**', 
    `dim_id` bigint COMMENT '**', 
    `dim_name` string COMMENT '***', 
    `adcrttype` string COMMENT '***')
  COMMENT '***'
  PARTITIONED BY ( 
    `dim_type` string)
  ROW FORMAT DELIMITED 
    FIELDS TERMINATED BY '\t' 
  STORED AS INPUTFORMAT 
    'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' 
  OUTPUTFORMAT 
    'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
  LOCATION
    'hdfs://ns1018/user/jd_ad/ads_sz/fdm.db/fdm_szad_t_exp_dim_day'
  TBLPROPERTIES (
    'mart_name'='jd_ad', 
    'orc.compress'='SNAPPY', 
    'transient_lastDdlTime'='1529396655')
  </code></pre>
  
  <p>this is bdm.bdm_szad_kafka_ad_media_click_hour schema:</p>
  
  <pre><code>CREATE EXTERNAL TABLE `bdm.bdm_szad_kafka_ad_media_click_hour`( 
  ...
    `position_id` string COMMENT '***'
  ...)
  COMMENT '***'
  PARTITIONED BY ( 
    `ftime` bigint)
  ROW FORMAT DELIMITED 
    FIELDS TERMINATED BY '\t' 
  STORED AS INPUTFORMAT 
    'com.hadoop.mapred.DeprecatedLzoTextInputFormat' 
  OUTPUTFORMAT 
    'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
  LOCATION
    'hdfs://ns1018/user/jd_ad/ads_sz/bdm.db/bdm_szad_kafka_ad_media_click_hour'
  TBLPROPERTIES (
    'SENSITIVE_TABLE'='FALSE', 
    'last_modified_by'='ads_sz', 
    'last_modified_time'='1540360230', 
    'mart_name'='jd_ad', 
    'transient_lastDdlTime'='1574760932')
  </code></pre>
  
  <p>this is query :</p>
  
  <pre><code>select
      t1.dim_id,
      t2.position_id
  from
  (select
      cast(dim_id as string) dim_id
  from fdm.fdm_szad_t_exp_dim_day) t1
  join
  (select
      position_id
  from bdm.bdm_szad_kafka_ad_media_click_hour
  WHERE ftime &gt;= 2020030100 and ftime &lt; 2020030101 and agency_id != 2390456) t2
  on t1.dim_id = t2.position_id
   ;
  </code></pre>
  
  <p>this is log of part:</p>
  
  <pre><code>Diagnostic Messages for this Task:
  
  Error: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row [Error getting row data with exception java.lang.ClassCastException: org.apache.hadoop.io.Text cannot be cast to org.apache.hadoop.io.LongWritable
  
        at org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableLongObjectInspector.get(WritableLongObjectInspector.java:36)
        at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:233)
        at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:366)
        at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:202)
        at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:188)
        at org.apache.hadoop.hive.ql.exec.MapOperator.toErrorMessage(MapOperator.java:571)
        at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:540)
        at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:163)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:453)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
        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:1830)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:162)
   ]
        at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:172)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:453)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168
        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:1830)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:162)
  
  Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row [Error getting row data with exception java.lang.ClassCastException: org.apache.hadoop.io.Text cannot be cast to org.apache.hadoop.io.LongWritable
  
        at org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableLongObjectInspector.get(WritableLongObjectInspector.java:36)
        at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:233)
        at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:366)
        at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:202)
        at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:188)
        at org.apache.hadoop.hive.ql.exec.MapOperator.toErrorMessage(MapOperator.java:571)
        at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:540)
        at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:163)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:453)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
        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:1830)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:162)
   ]
  
        at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:545)
        at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:163)
        ... 8 more
  
  Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public org.apache.hadoop.io.Text org.apache.hadoop.hive.ql.udf.UDFToString.evaluate(org.apache.hadoop.io.LongWritable)  on object org.apache.hadoop.hive.ql.udf.UDFToString@c2e3264 of class org.apache.hadoop.hive.ql.udf.UDFToString with arguments {泡泡射击_横幅:org.apache.hadoop.io.Text} of size 1
        at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:1001)
        at org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.evaluate(GenericUDFBridge.java:180)
        at org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:186)
        at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
        at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:65)
        at org.apache.hadoop.hive.ql.exec.SelectOperator.process(SelectOperator.java:81)
        at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:839)
        at org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:97)
        at org.apache.hadoop.hive.ql.exec.MapOperator$MapOpCtx.forward(MapOperator.java:164)
        at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:535)
        ... 9 more
  
  Caused by: java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:977)
        ... 18 more
  </code></pre>