hive supports tables in json format

Problem description: The data is stored in json format, you need to create a hive table to support json format

 

(1) The lower version of hive creates a json format table, which needs to add jar..., hive2.3.0 version supports json format table by default

 

(2) To create a table in json format, you need to create a table statement plus

ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
STORED AS TEXTFILE

 

The complete sql is as follows:

CREATE EXTERNAL TABLE `test_json`(
field type...)
PARTITIONED BY (partition..)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
STORED AS TEXTFILE
LOCATION '...';

 

(3) Although hive2.3.0 directly supports the creation of json format tables and select *, but the select count(1) operation will report an error that org.apache.hive.hcatalog.data.JsonSerDe cannot be found

Solution:

Add the following configuration to hive-site.xml, after restarting hive, it will return to normal

<property>
<name>hive.aux.jars.path</name>
<!--Modify according to your actual path-->
<value>/home/hadoop/apache-hive-2.3.2-bin/hcatalog/share/hcatalog/hive-hcatalog-core-2.3.2.jar</value>
</property>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326085281&siteId=291194637