Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException when trying to access int field #541

Closed
ghost opened this issue Aug 31, 2015 · 1 comment
Closed

ClassCastException when trying to access int field #541

ghost opened this issue Aug 31, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 31, 2015

I have a es-hive table created using this statement below 馃憤

CREATE EXTERNAL TABLE stg.elastic_test (id int, name string)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.resource' = 'work/test','es.nodes' = '#es_host:9200',
'es.field.read.empty.as.null' = 'yes','es.index.read.missing.as.empty'='yes');

When i insert data (only about 8 records ) into this table, the insertion operation completes successfully. But when i try to access the data using "select * from stg.elastic_test" , it throws this error 馃憤

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.IntWritable

The same table , if i change id to string type and cast the the values as string when inserting, it works fine. Can you tell me what is the issue here and how can that be fixed ?

Thanks,
Nivetha

@costin
Copy link
Member

costin commented Aug 31, 2015

The error is caused by a type mismatch in your mapping - namely you are trying to read a Long as a Int. This typically occurs due to automatic mapping and it explained in the docs (as well on how to address it), namely here.

@costin costin closed this as completed Aug 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant