简体   繁体   English

Hive JSON SerDe — ClassCastException:无法将java.lang.Integer强制转换为java.lang.Double

[英]Hive JSON SerDe — ClassCastException: java.lang.Integer cannot be cast to java.lang.Double

I'm trying to use Hive JSON SerDe to put Twitter JSON into Hive tables. 我正在尝试使用Hive JSON SerDe将Twitter JSON放入Hive表中。 I first import the JSON into one table defined by ROW FORMAT SERDE and then import it to another table stored as an RCFile. 我首先将JSON导入到ROW FORMAT SERDE定义的一个表中,然后将其导入到以RCFile存储的另一张表中。 It works up to a point but then I get a ClassCastException of the following nature: 它可以工作到一定程度,但是随后我得到了以下性质的ClassCastException:

java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row [Error getting row data with exception java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
    at org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaDoubleObjectInspector.get(JavaDoubleObjectInspector.java:40)
    at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:259)
    at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:307)
    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:220)
    at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:667)
    at org.apache.hadoop.hive.ql.exec.ExecMapper.map(ExecMapper.java:141)
    at org.apache.hadoop

Here's the schema I'm using to define the SerDe table: 这是我用来定义SerDe表的模式:

CREATE EXTERNAL TABLE gh_raw (
   coordinates struct <
      coordinates: array <double>,
      type: string>,
   created_at string,
   entities struct <
      hashtags: array <struct <text: string>>,
      media: array <struct <
            display_url: string,
            expanded_url: string,
            media_url: string,
            media_url_https: string,
            sizes: struct <
               large: struct <
                  h: int,
                  resize: string,
                  w: int>,
               medium: struct <
                  h: int,
                  resize: string,
                  w: int>,
               small: struct <
                  h: int,
                  resize: string,
                  w: int>,
               thumb: struct <
                  h: int,
                  resize: string,
                  w: int>>,
            type: string,
            url: string>>,
      urls: array <struct <
            display_url: string,
            expanded_url: string,
            url: string>>,
      user_mentions: array <struct <
            id: int,
            name: string,
            screen_name: string>>>,
   geo struct <
      coordinates: array <double>,
      type: string>,
   id_str string,
   in_reply_to_screen_name string,
   in_reply_to_status_id_str string,
   in_reply_to_user_id_str string,
   place struct <
      attributes: struct <
         locality: string,
         region: string,
         street_address: string>,
      bounding_box: struct <
         coordinates: array <array <array <double>>>,
         type: string>,
      country: string,
      country_code: string,
      full_name: string,
      name: string,
      place_type: string,
      url: string>,
   possibly_sensitive boolean,
   retweeted_status struct <
      coordinates: struct <
         coordinates: array <double>,
         type: string>,
      created_at: string,
      entities: struct <
         hashtags: array <struct <
               text: string>>,
         media: array <struct <
               display_url: string,
               expanded_url: string,
               media_url: string,
               media_url_https: string,
               sizes: struct <
                  large: struct <
                     h: int,
                     resize: string,
                     w: int>,
                  medium: struct <
                     h: int,
                     resize: string,
                     w: int>,
                  small: struct <
                     h: int,
                     resize: string,
                     w: int>,
                  thumb: struct <
                     h: int,
                     resize: string,
                     w: int>>,
               type: string,
               url: string>>,
         urls: array <struct <
               display_url: string,
               expanded_url: string,
               url: string>>,
         user_mentions: array <struct <
               id: int,
               name: string,
               screen_name: string>>>,
      favorited: boolean,
      geo: struct <
         coordinates: array <double>,
         type: string>,
      id_str: string,
      in_reply_to_screen_name: string,
      in_reply_to_status_id_str: string,
      in_reply_to_user_id_str: string,
      place: struct <
         attributes: struct <
         locality: string,
         region: string,
         street_address: string
         >,
         bounding_box: struct <
            coordinates: array <array <array <double>>>,
            type: string>,
         country: string,
         country_code: string,
         full_name: string,
         name: string,
         place_type: string,
         url: string>,
      possibly_sensitive: boolean,
      scopes: struct <
         followers: boolean>,
      source: string,
      text: string,
      truncated: boolean,
      user: struct <
         contributors_enabled: boolean,
         created_at: string,
         default_profile: boolean,
         default_profile_image: boolean,
         description: string,
         favourites_count: int,
         followers_count: int,
         friends_count: int,
         geo_enabled: boolean,
         id: int,
         id_str: string,
         is_translator: boolean,
         lang: string,
         listed_count: int,
         `location`: string,
         name: string,
         profile_background_color: string,
         profile_background_image_url: string,
         profile_background_image_url_https: string,
         profile_background_tile: boolean,
         profile_banner_url: string,
         profile_image_url: string,
         profile_image_url_https: string,
         profile_link_color: string,
         profile_sidebar_border_color: string,
         profile_sidebar_fill_color: string,
         profile_text_color: string,
         profile_use_background_image: boolean,
         protected: boolean,
         screen_name: string,
         statuses_count: int,
         time_zone: string,
         url: string,
         utc_offset: int,
         verified: boolean>>,
   source string,
   text string,
   truncated boolean,
   user struct <
      contributors_enabled: boolean,
      created_at: string,
      default_profile: boolean,
      default_profile_image: boolean,
      description: string,
      favourites_count: int,
      followers_count: int,
      friends_count: int,
      geo_enabled: boolean,
      id: int,
      id_str: string,
      is_translator: boolean,
      lang: string,
      listed_count: int,
      `location`: string,
      name: string,
      profile_background_color: string,
      profile_background_image_url: string,
      profile_background_image_url_https: string,
      profile_background_tile: boolean,
      profile_banner_url: string,
      profile_image_url: string,
      profile_image_url_https: string,
      profile_link_color: string,
      profile_sidebar_border_color: string,
      profile_sidebar_fill_color: string,
      profile_text_color: string,
      profile_use_background_image: boolean,
      protected: boolean,
      screen_name: string,
      statuses_count: int,
      time_zone: string,
      url: string,
      utc_offset: int,
      verified: boolean>
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION '/user/ahanna/gh_raw';

I figure this is crashing when finding a set of coordinates or a bounding box. 我发现找到一组坐标或边界框时这崩溃了。

I think this is a bug with the JSON SerDe I'm using but I'm not sure. 我认为这是我正在使用的JSON SerDe的错误,但不确定。 I've compiled the one I'm using from scratch, from someone who said they have fixed this issue, but no go: https://github.com/brndnmtthws/Hive-JSON-Serde 我已经从头开始编译了我正在使用的那个,有人说他们已经解决了这个问题,但是没有去: https//github.com/brndnmtthws/Hive-JSON-Serde

Try this SerDe - https://github.com/rcongiu/Hive-JSON-Serde . 试试这个SerDe- https://github.com/rcongiu/Hive-JSON-Serde I was getting the same Exception while trying to read coordinates from tweets. 尝试从推文中读取坐标时,我遇到了相同的异常。 Using this fixed it for me! 使用此修复它对我来说!

The binary's available here so you don't need to build it - http://www.congiu.net/hive-json-serde/ 二进制文件在这里可用,因此您无需构建它-http://www.congiu.net/hive-json-serde/

Try bigint instead of int. 尝试使用bigint而不是int。 It works for me. 这个对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hibernate:java.lang.ClassCastException:java.lang.Integer无法强制转换为java.lang.Double - Hibernate : java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double java.lang.ClassCastException:java.lang.Integer无法强制转换为java.lang.Double - java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double java.lang.Integer无法转换为java.lang.Double - java.lang.Integer cannot be cast to java.lang.Double “ errorMessage”:“ java.lang.Integer无法转换为java.lang.Double” - “errorMessage”: “java.lang.Integer cannot be cast to java.lang.Double” java.lang.ClassCastException:无法强制转换java.lang.Integer - java.lang.ClassCastException: java.lang.Integer cannot be cast java.lang.ClassCastException:无法转换为java.lang.Integer - java.lang.ClassCastException: cannot be cast to java.lang.Integer 三星电视 Web 应用程序的 Tizen SDK 抛出 java.lang.Integer 无法转换为 java.lang.Double - Tizen SDK for Samsung TV Web App throws java.lang.Integer cannot be cast to java.lang.Double java.lang.ClassCastException:java.lang.String 无法转换为 java.lang.Double - java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double java.lang.ClassCastException:java.lang.Double无法强制转换为java.lang.String - java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String ClassCastException:无法将ApiVersionImpl强制转换为java.lang.Integer - ClassCastException: ApiVersionImpl cannot be cast to java.lang.Integer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM