如何将数据从hdfs加载到hive表

mi7gmzs6  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(217)

请告诉我如何将数据从hdfs加载到hive表??因为我把昨天下载的推文弄丢了。加载我在下面使用的数据。

LOAD DATA LOCAL INPATH '/user/hue/twitter/tweets/2017/03/10' 
OVERWRITE INTO TABLE tweets 
PARTITION (datehour=20170310).

给我一个正确的查询这是我的表。我分两步发送

CREATE EXTERNAL TABLE twitter.tweets ( 
id BIGINT, 
created_at STRING, 
source STRING, 
favorited BOOLEAN, 
retweeted_status STRUCT< 
                 text:STRING,   
                 user:STRUCT < screen_name:STRING, name:STRING >, 
                 retweet_count:INT
                 >, 
entities STRUCT< 
                 urls:ARRAY<STRUCT<expanded_url:STRING>>, 
                 user_mentions:ARRAY<STRUCT <
                                             screen_name:STRING,    
                                             name:STRING
                                            >
                                     >,
                 hashtags:ARRAY<STRUCT<text:STRING>>
               >, 
text STRING, 
–user STRUCT< 
      screen_name:STRING, 
      name:STRING,  
      friends_count:INT, 
      followers_count:INT, 
      statuses_count:INT, 
      verified:BOOLEAN, 
      utc_offset:INT, 
      time_zone:STRING
      >, 
in_reply_to_screen_name STRING )
PARTITIONED BY (datehour INT) 
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe' 
LOCATION '/twitter';

样本数据:附加的数据很少

{"filter_level":"low","retweeted":false,"in_reply_to_screen_‌​name":null,"possibly‌​_sensitive":false,"t‌​runcated":false,"lan‌​g":"en","in_reply_to‌​_status_id_str":null‌​,"id":84064934204214‌​8865,"extended_entit‌​ies":{"media":[{"siz‌​es":{"thumb":{"w":15‌​0,"resize":"crop","h‌​":150},"small":{"w":‌​340,"resize":"fit","‌​h":340},"medium":{"w‌​":600,"resize":"fit"‌​,"h":600},"large":{"‌​w":960,"resize":"fit‌​","h":960}},"source_‌​user_id":15934076,

我发现将数据从hdfs加载到hive表是,

LOAD DATA INPATH '/user/hue/twitter/tweets/2017/03/10' OVERWRITE INTO TABLE tweets PARTITION (datehour=20170310).

这是正确的,我会失去我的源文件??如果是,那么什么是解决方案查询??

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题