title: Hive: column type of Decimal(12,9) throws NullPointerException with JSONSerDe
body: <p>I have a an external table that points to json data. I am using serde <code>org.apache.hive.hcatalog.data.JsonSerDe</code>.<br>
  I have created a view on top of this external table using DDL:</p>
  
  <pre><code>CREATE VIEW `my_table` AS SELECT
  a.col1,
  a.col2,
  ...
  ...
  a.longitude,
  a.latitude
  FROM
  (SELECT
  mytable.body.col1,
  mytable.body.col2,
  ....
  ..
  mytable.body.longitude,
  mytable.body.latidute,
  ROW_NUMBER() OVER( PARTITION BY mytable.body.col1, mytable.body.col1 ORDER BY mytable.body.col3 DESC )
  AS rownum FROM mydb.myExtTable) AS a where a.rownum=1
  </code></pre>
  
  <p>When I am doing a <code>SELECT * FROM mytable</code> it is giving me a <code>NullPointerException</code>:</p>
  
  <pre><code>Vertex failed, vertexName=Reducer 2, vertexId=vertex_1529530522022_75616_22_01, diagnostics=[Task failed, taskId=task_1529530522022_75616_22_01_000000, diagnostics=[TaskAttempt 0 failed, info=[Error: Failure while running task:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row (tag=0) [Error getting row data with exception java.lang.NullPointerException
          at org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryHiveDecimal.init(LazyBinaryHiveDecimal.java:47)
          at org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct.uncheckedGetField(LazyBinaryStruct.java:267)
          at org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct.getField(LazyBinaryStruct.java:204)
          at org.apache.hadoop.hive.serde2.lazybinary.objectinspector.LazyBinaryStructObjectInspector.getStructFieldData(LazyBinaryStructObjectInspector.java:64)
          at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:354)
          at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:354)
          at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:354)
          at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:198)
          at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:184)
          at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordSource$GroupIterator.next(ReduceRecordSource.java:347)
          at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordSource.pushRecord(ReduceRecordSource.java:274)
          at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordProcessor.run(ReduceRecordProcessor.java:266)
          at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:150)
          at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:139)
          at org.apache.tez.runtime.LogicalIOProcessorRuntimeTask.run(LogicalIOProcessorRuntimeTask.java:347)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:194)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:185)
          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:1866)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.callInternal(TezTaskRunner.java:185)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.callInternal(TezTaskRunner.java:181)
          at org.apache.tez.common.CallableWithNdc.call(CallableWithNdc.java:36)
          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)
   ]
          at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:173)
          at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:139)
          at org.apache.tez.runtime.LogicalIOProcessorRuntimeTask.run(LogicalIOProcessorRuntimeTask.java:347)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:194)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:185)
          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:1866)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.callInternal(TezTaskRunner.java:185)
          at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.callInternal(TezTaskRunner.java:181)
          at org.apache.tez.common.CallableWithNdc.call(CallableWithNdc.java:36)
          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)
  </code></pre>
  
  <p>I have just 2 records as JSON.<br>
  The two JSON are like:</p>
  
  <pre><code>{"header": {"header1":"value1", "header2": "value2"}, "body": {"col1": "col1 value", "col2": "col2 value",.... "latitude": 39.921302, "longitude": -74.879928}}
  {"header": {"header1":"value1", "header2": "value2"}, "body": {"col1": "col1 value", "col2": "col2 value",.... "latitude": 43658734.438, "longitude": 3453.3453}} 
  </code></pre>
  
  <p>The weird part is when I run a <code>SELECT</code> on my VIEW using only 1 record it fetches me correctly, but running it for both records together, it gives me Exception.  </p>
  
  <p>When I am removing the <code>"latitude": 43658734.438, "longitude": 3453.3453</code> values from JSON data(from the 2nd record), things are running fine again.<br>
  The columns <code>longitude</code> and <code>latitude</code> are of type <code>decimal(12,9)</code>.<br>
  As I suspect, is there any issue with the column value ?<br>
  But if the values are posing issue while running both records together, why are they running fine individually (Note: when running the 2nd record indivdually , however these 2 column values for this record is getting replaced by <code>NULL</code>).<br>
  What could be the issue ?  </p>
  
  <p>Please help.</p>