Hive 设置 DDL 命令的输出格式:JSON 或者 TEXT

配置项

如果不配置,默认为 text。

<property>
    <name>hive.ddl.output.format</name>
    <value>text</value>
    <description>
      The data format to use for DDL output.  One of "text" (for human
      readable text) or "json" (for a json object).
    </description>
  </property>

text 测试

hive> set hive.ddl.output.format=text;
hive> show tables;
OK
aaaaa
call_center
catalog_page
catalog_returns
catalog_sales
customer
customer_address
customer_demographics
date_dim
foo
household_demographics
income_band
inventory
item
promotion
reason
ship_mode
store
store_returns
store_returns_no_partition
store_sales
t_query1
time_dim
warehouse
web_page
web_returns
web_sales
web_site
Time taken: 0.019 seconds, Fetched: 28 row(s)

json

使用 json 格式,更容易使用程序处理。

hive> set hive.ddl.output.format=json;
hive> use tpcds_hdfs_orc_3;
OK
Time taken: 0.354 seconds
hive> show tables;
OK
{"tables":["aaaaa","call_center","catalog_page","catalog_returns","catalog_sales","customer","customer_address","customer_demographics","date_dim","foo","household_demographics","income_band","inventory","item","promotion","reason","ship_mode","store","store_returns","store_returns_no_partition","store_sales","t_query1","time_dim","warehouse","web_page","web_returns","web_sales","web_site"]}

hive>  desc web_site;
OK
{"columns":[{"name":"web_site_sk","type":"bigint"},{"name":"web_site_id","type":"char(16)"},{"name":"web_rec_start_date","type":"date"},{"name":"web_rec_end_date","type":"date"},{"name":"web_name","type":"varchar(50)"},{"name":"web_open_date_sk","type":"bigint"},{"name":"web_close_date_sk","type":"bigint"},{"name":"web_class","type":"varchar(50)"},{"name":"web_manager","type":"varchar(40)"},{"name":"web_mkt_id","type":"int"},{"name":"web_mkt_class","type":"varchar(50)"},{"name":"web_mkt_desc","type":"varchar(100)"},{"name":"web_market_manager","type":"varchar(40)"},{"name":"web_company_id","type":"int"},{"name":"web_company_name","type":"char(50)"},{"name":"web_street_number","type":"char(10)"},{"name":"web_street_name","type":"varchar(60)"},{"name":"web_street_type","type":"char(15)"},{"name":"web_suite_number","type":"char(10)"},{"name":"web_city","type":"varchar(60)"},{"name":"web_county","type":"varchar(30)"},{"name":"web_state","type":"char(2)"},{"name":"web_zip","type":"char(10)"},{"name":"web_country","type":"varchar(20)"},{"name":"web_gmt_offset","type":"decimal(5,2)"},{"name":"web_tax_percentage","type":"decimal(5,2)"}]}	 	 
Time taken: 0.033 seconds, Fetched: 1 row(s)

可以重定向到文件

hive --hiveconf hive.ddl.output.format=json -e "use tpcds_hdfs_orc_3;desc web_site" > web_site
[houzhizhen@localhost ~]$ cat web_site 
{"columns":[{"name":"web_site_sk","type":"bigint"},{"name":"web_site_id","type":"char(16)"},{"name":"web_rec_start_date","type":"date"},{"name":"web_rec_end_date","type":"date"},{"name":"web_name","type":"varchar(50)"},{"name":"web_open_date_sk","type":"bigint"},{"name":"web_close_date_sk","type":"bigint"},{"name":"web_class","type":"varchar(50)"},{"name":"web_manager","type":"varchar(40)"},{"name":"web_mkt_id","type":"int"},{"name":"web_mkt_class","type":"varchar(50)"},{"name":"web_mkt_desc","type":"varchar(100)"},{"name":"web_market_manager","type":"varchar(40)"},{"name":"web_company_id","type":"int"},{"name":"web_company_name","type":"char(50)"},{"name":"web_street_number","type":"char(10)"},{"name":"web_street_name","type":"varchar(60)"},{"name":"web_street_type","type":"char(15)"},{"name":"web_suite_number","type":"char(10)"},{"name":"web_city","type":"varchar(60)"},{"name":"web_county","type":"varchar(30)"},{"name":"web_state","type":"char(2)"},{"name":"web_zip","type":"char(10)"},{"name":"web_country","type":"varchar(20)"},{"name":"web_gmt_offset","type":"decimal(5,2)"},{"name":"web_tax_percentage","type":"decimal(5,2)"}]}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值