hive 导出json格式 文件_hive支持json格式的数据
Hive
支持完全
json
格式的數(shù)據(jù)
?
現(xiàn)有
json
格式的數(shù)據(jù)
test.txt
,如下
{"name":"zhang","age":"20","sex":"man"}
{"name":"li","age":"21","sex":"man"}
{"name":"wu","age":"18","sex":"woman"}
?
將
test.txt
上傳到
hdfs
中
Hdfs?dfs
–
put?test.txt?/tmp/test
?
在
hive
中建內(nèi)部表(或外部表)
,來讀取該文件
Create?[external]?table?test
(
name?string,
age?string,
sex?string
)?row?format?serde?‘org.apache.hive.hcatalog.data.JsonSerde’
Stored?as?textfile?location?‘/tmp/test’;
?
查詢數(shù)據(jù)如下
Select?*?from?test;
注意:
當(dāng)建表時(shí)如果出現(xiàn)以下錯(cuò)誤:
FAILED:?Execution?Error,?return?code?1?from?org.apache.hadoop.hive.ql.exec.DDLTask.
Cannot?validate?serde
說明在
hive
的服務(wù)端沒有
hive_hcatalog_core_[
版本號(hào)
].jar
這個(gè)包,
找到該包上傳
到
hive
服務(wù)端的
lib
目錄下,重啟服務(wù)即可。
曾在
hive
中手動(dòng)的添加該包:
add
jar?.jar
發(fā)現(xiàn)不像建立函數(shù)那樣可以永久保存,
只是在當(dāng)前會(huì)話中使用
jar
包,重新登錄不可用。
Hive
支持不完全
json
格式的數(shù)據(jù)
?
現(xiàn)有
json
格式的數(shù)據(jù)
test.txt
,如下
1|{"name":"zhang","age":"20","sex":"man"}
2|{"name":"li","age":"21","sex":"man"}
總結(jié)
以上是生活随笔為你收集整理的hive 导出json格式 文件_hive支持json格式的数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: peewee mysql自动断开_fla
- 下一篇: 结构体内元素不确定_查漏补缺!高中三年生