In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how Hive3.1.0 uses compound data types. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
I. Overview
The main demonstration is how to write the corresponding HQL table statement when there are multiple compound data types in the redundant single table.
II. Demonstration of examples
1. Suppose we have some student information data. The fields include name name String type, hobby interests array type, course and score course map type, info mobile number and age struct type. Let's look directly at the data file student1.txt:
Lujisen1,basketball | football,yuwen:80 | shuxue:81,18668984418 | 20lujisen1 camera baskets | volleyball,yuwen:90 | shuxue:91,18668984417 | 21
two。 This table contains three data types: array, map and struct. How to build a table to divide the data? Create the table statement as follows:
Create table studetn1 (name string,interests array,course map,info struct) row format delimited fields terminated by', 'collection items terminated by' | 'map keys terminated by': 'lines terminated by'\ n'
Let's analyze the table creation statement:
1) .row format delimited this is a row formatting restriction. Let's specify how the fields in the row are separated.
2) fields terminated by',': specifies that each field is separated by a comma
3) .collection items terminated by'| 'delimiters of compound data types map and array, with internal elements separated by "|"
4) .map keys terminated by': 'here is the map-specific setting that specifies that the key/value delimiter in map is ":"
5). Lines terminated by'\ n' it's easier to understand the delimiter of each line specified here.
3. Next, I will actually do it. Use the above statement to create a table student1 and take a screenshot:
4. Load data:
Load data local inpath'/ root/student1.txt' into table student1
5. Query the following data table to verify that the data is loaded successfully:
There may be other complex data types, and the principle is basically the same.
Thank you for reading! This is the end of the article on "how to use compound data types in Hive3.1.0". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.