Table of contents
- text
- First create the table
- Import data and query
- other considerations
- Summarize
text
The existing file is in csv format and needs to be imported into hive. Set the content of csv as follows
1 2 |
|
First create the table
1 2 3 4 5 6 7 |
|
Import data and query
1 2 |
|
other considerations
If the created table is in parquet format, can it load and import csv file?
1 2 3 4 5 6 7 8 9 10 11 |
|
An error will be reported when using
Failed with exception java.io.IOException:java.lang.RuntimeException: hdfs://192.168.10.101:8020/user/hive/warehouse/csv2/csv2.csv is not a Parquet file. expected magic number at tail [80, 65, 82, 49] but found [44, 50, 52, 10]
**No, you need to import it into textfile first, and then import it into parquet from the temporary table,** as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Summarize
- The key is to introduce org.apache.hadoop.hive.serde2.OpenCSVSerde
csv
To save tohive
,parquet
you need to save astextfile