# Issue with Hive mapping of ES nested fields

**URL:** <https://discuss.elastic.co/t/issue-with-hive-mapping-of-es-nested-fields/43421>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [March 3, 2016, 5:02pm UTC](https://discuss.elastic.co/t/issue-with-hive-mapping-of-es-nested-fields/43421 "2016-03-03T17:02:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yari\_Marchetti](https://avatars.discourse-cdn.com/v4/letter/y/82dd89/32.png) [@Yari\_Marchetti](https://discuss.elastic.co/u/Yari_Marchetti)\
**Post date:** [March 3, 2016, 5:02pm UTC](https://discuss.elastic.co/t/issue-with-hive-mapping-of-es-nested-fields/43421/1 "2016-03-03T17:02:15Z")

</div>

Hello,  
I'm having some issue with mapping to an Hive field to a ES nested field. On ES I have a document like:

{  
"name": "test1",  
"custom\_data": {  
"session\_id": "d41442b987b5bc8103000a2cc2cfb062",  
}  
}

In Hive I'm trying to map it with:

CREATE EXTERNAL TABLE test\_es (sessionid string, name string)  
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'  
TBLPROPERTIES('es.resource' = 'test/event',  
'es.index.auto.create' = 'false',  
'es.nodes' = 'localhost',  
'es.mapping.names' = 'sessionid:custom\_data.session\_id, name:name'  
)

but when I query with a simple:

SELECT \* FROM test\_es

I keep on getting this error:

Error: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing writable {custom\_data=[]}

I'm running Hive 1.1.0 and ES-Hadoop 2.2.0-rc1. Do you have any idea?

Thanks,  
Yari

---

<div class="post-metadata">

**Author:** ![Yari\_Marchetti](https://avatars.discourse-cdn.com/v4/letter/y/82dd89/32.png) [@Yari\_Marchetti](https://discuss.elastic.co/u/Yari_Marchetti)\
**Post date:** [March 7, 2016, 10:57am UTC](https://discuss.elastic.co/t/issue-with-hive-mapping-of-es-nested-fields/43421/2 "2016-03-07T10:57:51Z")

</div>

In the end I found the issue: it looks like it was due to the top level structure being unavailable, custom\_data in this example, which it's triggering the error (I tried setting 'es.field.read.empty.as.null' to true but no benefit). Is there any way to prevent this from happening?

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [March 12, 2016, 2:15pm UTC](https://discuss.elastic.co/t/issue-with-hive-mapping-of-es-nested-fields/43421/3 "2016-03-12T14:15:31Z")

</div>

If the top level field is not available, so is the nested structure underneath it. Potentially some checks can be added to try and mock the missing field - a github issue would be great in this case.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:25pm UTC](https://discuss.elastic.co/t/issue-with-hive-mapping-of-es-nested-fields/43421/4 "2017-07-06T13:25:47Z")

</div>


