# Elasticsearch - Hive datatype cast issues - Errors while query the data through HIVE

**URL:** <https://discuss.elastic.co/t/elasticsearch-hive-datatype-cast-issues-errors-while-query-the-data-through-hive/170251>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [February 27, 2019, 9:58pm UTC](https://discuss.elastic.co/t/elasticsearch-hive-datatype-cast-issues-errors-while-query-the-data-through-hive/170251 "2019-02-27T21:58:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksivaus](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@ksivaus](https://discuss.elastic.co/u/ksivaus)\
**Post date:** [February 27, 2019, 9:58pm UTC](https://discuss.elastic.co/t/elasticsearch-hive-datatype-cast-issues-errors-while-query-the-data-through-hive/170251/1 "2019-02-27T21:58:52Z")

</div>

Hi All,

```
I am currently working with Elasticsearch - Hive integration . I have created the index and loaded the data successfully, with the below mapping...

```

curl -XPOST localhost:9200/sales\_v3 -d '{  
"settings" : {  
"number\_of\_shards" : 3,  
"number\_of\_replicas" : 1  
},  
"mappings" : {  
"fact" : {  
"\_source" : { "enabled" : false },  
"properties" : {  
"PROD\_ID" : { "type" : "integer" },  
"CUST\_ID" : { "type" : "integer" },  
"TIME\_ID" : { "type" : "date", "format" : "yyyy-MM-dd" },  
"CHANNEL\_ID" : { "type" : "text" },  
"PROMO\_ID" : { "type" : "integer" },  
"QUANTITY\_SOLD" : { "type" : "text" },  
"AMOUNT\_SOLD" : { "type" : "double" },  
"UNIT\_COST" : { "type" : "double" },  
"UNIT\_PRICE" : { "type" : "double" }  
}  
}  
}  
}'

my data in json file is as below -

# head -6 /tmp/salesv3\_newe.json

{ "index" : { "\_index" : "sales\_v3", "\_type" : "fact", "\_id" : "1"} }  
{ "prod\_id": 13, "cust\_id": 987, "time\_id": "1998-01-10", "channel\_id": 3, "promo\_id": 999, "quantity\_sold": 1, "amount\_sold": 1232.16, "unit\_cost": 783.03, "unit\_price": "1232.16" }  
{ "index" : { "\_index" : "sales\_v3", "\_type" : "fact", "\_id" : "2"} }  
{ "prod\_id": 13, "cust\_id": 1660, "time\_id": "1998-01-10", "channel\_id": 3, "promo\_id": 999, "quantity\_sold": 1, "amount\_sold": 1232.16, "unit\_cost": 783.03, "unit\_price": "1232.16" }  
{ "index" : { "\_index" : "sales\_v3", "\_type" : "fact", "\_id" : "3"} }  
{ "prod\_id": 13, "cust\_id": 1762, "time\_id": "1998-01-10", "channel\_id": 3, "promo\_id": 999, "quantity\_sold": 1, "amount\_sold": 1232.16, "unit\_cost": 783.03, "unit\_price": "1232.16" }

Later I have created my Hive external table as below -

CREATE EXTERNAL TABLE sales (  
prod\_id INT,  
cust\_id INT,  
time\_id TIMESTAMP,  
channel\_id STRING,  
promo\_id INT,  
quantity\_sold STRING,  
amount\_sold DOUBLE,  
unit\_cost DOUBLE,  
unit\_price DOUBLE)  
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'  
TBLPROPERTIES('es.nodes' = 'localhost:9200', 'es.resource' = 'sales\_v3/fact', 'es.query' = '?q=\*');

I am using the Elasticsearch 6.2.4 and the same elasticsearch-hadoop jar

# ls -l /usr/lib/hive/lib/elastic\*

-rwxr-xr-x 1 root root 890273 Feb 25 12:34 /usr/lib/hive/lib/elasticsearch-hadoop-6.2.4.jar

When I query the data - this is error message I see. How would I resolve this. Please help and Thanks in advance.

```
> select * from sales;

```

OK  
_Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text_  
_Time taken: 0.473 seconds_

Thanks  
ksivaus

---

<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:** [March 27, 2019, 9:58pm UTC](https://discuss.elastic.co/t/elasticsearch-hive-datatype-cast-issues-errors-while-query-the-data-through-hive/170251/2 "2019-03-27T21:58:55Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
