Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Basic use of Hive

Shulou Source: shulou.com Published: 2022-06-02 04:06:08 10月01日 Update

This article mainly explains "the basic use of Hive". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the basic use of Hive".

Hive has three complex data types: ARRAY, MAP, and STRUCT. ARRAY and MAP are similar to Array and Map in Java, while STRUCT, like Struct in C, encapsulates a collection of named fields, and complex data types allow for any level of nesting.

Create a datasheet

Create table test (name string,friends array,children map,address struct) row format delimited fields terminated by', 'collection items terminated by' _ 'map keys terminated by': 'lines terminated by'\ n

View data structures

Hive (default) > desc test;OKcol_name data_type commentname string friends array children map address struct Time taken: 0.053 seconds, Fetched: 4 row (s)

test data

Liming,zhangsan_lisi,xiao ming:12_xiaoxiao ming:3,haidian_beijingwangwu,zhaoliu_sunba_qianer,xiao wang:18_xiaoxiao wang:9,chao yang_beijing

Load test data

Hive (default) > load data local inpath'/ opt/module/data/people.txt' into table test;Loading data to table default.testTable default.test stats: [numFiles=1, numRows=0, totalSize=141, rawDataSize=0] OKTime taken: 0.354 seconds

View data content

Hive (default) > select * from test;OKtest.name test.friends test.children test.addressliming ["zhangsan", "lisi"] {"xiao ming": 12, "xiaoxiao ming": 3} {"street": "haidian", "city": "beijing"} wangwu ["zhaoliu", "sunba", "qianer"] {"xiao wang": 18, "xiaoxiao wang": 9} {"street": "chao yang", "city": "beijing"} Time taken: 0.069 seconds, Fetched: 2 row (s)

# # Mysql to view the structure of hive table

View the fields of the table

# # loading data into hive

LOAD DATA LOCAL (local files need to add LOCAL) INPATH 'file path' OVERWRITE INTO TABLE table name

Thank you for your reading, the above is the content of "the basic use of Hive", after the study of this article, I believe you have a deeper understanding of the basic use of Hive, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Data content learning complexity fields files types structures tests names that is levels ideas situations data structures datasheets articles more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei Microsoft Apple vpn