Created 01-13-2017 03:01 PM
Hi,
I have a Hive table thus:
... text string from deserializer timestamp_ms string from deserializer truncated boolean from deserializer user struct<contributors_enabled:boolean,created_at:string,default_profile:boolean,default_profile_image:boolean,description:string,favourites_count:tinyint,follow_request_sent:string,followers_count:tinyint,following:string,friends_count:tinyint,geo_enabled:boolean,id:bigint,id_str:binary,is_translator:boolean,lang:string,listed_count:tinyint,location:string,name:string,notifications:string,profile_background_color:binary,profile_background_image_url:string,profile_background_image_url_https:string,profile_background_tile:boolean,profile_image_url:string,profile_image_url_https:string,profile_link_color:binary,profile_sidebar_border_color:binary,profile_sidebar_fill_color:binary,profile_text_color:binary,profile_use_background_image:boolean,protected:boolean,screen_name:string,statuses_count:smallint,time_zone:string,url:string,utc_offset:string,verified:boolean> from deserializer
When I try (using backticks because user is a reserved word):
select `user` from tweets;
I get this error (this is the full error):
Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.ClassCastException: java.lang.String cannot be cast to [B
I'm thinking, maybe I have to query user subfields, so I try:
select `user`.contributors_enabled from tweets;
and get:
FAILED: SemanticException [Error 10042]: Line 1:7 . Operator is only supported on struct or list of struct types 'contributors_enabled'
I also try:
select user.contributors_enabled from tweets;
and get:
FAILED: ParseException line 1:35 cannot recognize input near 'user' '.' 'contributors_enabled' in selection target
How do I interrogate user and its subfields? TIA!!
PS HDP 2.4 and e.g.
select text from tweets;
works fine.
Created 01-13-2017 05:33 PM
My first thought was using back tick but I see you have already tried it. Can you also try
Created 01-20-2017 10:32 AM
Thanks for your help. thirst two fail with the SemanticException error. The last one just prints out the field name as a literal.
Created 01-13-2017 07:52 PM
if you are using version 2.1.0 and earlier, you can try set hive.support.sql11.reserved.keywords=false;
and then try again without using the "`"
Created 01-13-2017 07:52 PM
And here is the documentation: