如何导出配置单元中的视图数据? [英] How can I export view data in hive?

查看:84
本文介绍了如何导出配置单元中的视图数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在蜂巢中创建了4个表(a,b,c,d),并通过联接在这些表的顶部创建了视图(x).

I have created 4 tables (a,b,c,d) in hive and created a view (x) on top of that tables by joining them.

-如何将x基本的csv数据从hdfs导出到本地?

-- How can i export the x underlying csv data from hdfs to local ?

-我如何将这个csv保留在hdfs中

-- How can i keep this csv in hdfs

对于表格,我们可以显示创建表格a ;

for tables , we can do show create table a;

这将显示基础csv存储在hdfs中的位置.

this will show the location of the hdfs where the underlying csv is stored.

hadoop fs从源路径和文件获取到目标路径和文件

hadoop fs get --from source_path_and_file --to dest_path_and_file

类似地,我如何从视图中获取csv数据到本地.

similarly how can i get the csv data from view into my local.

推荐答案

您可以使用以下方法将视图数据导出到CSV:

You can export view data to the CSV using this:

insert overwrite local directory '/user/home/dir' row format delimited fields terminated by ',' select * from view;

如果需要使用cat的单个文件,请在本地目录中串联文件:

Concatenate files in the local directory if you need single file using cat :

cat /user/home/dir/* > view.csv

或者,如果数据集较小,则可以在查询中添加order by,这将触发单个reducer并生成单个有序文件.如果数据集很大,则执行速度会很慢.

Alternatively if the dataset is small, you can add order by in the query, this will trigger single reducer and produce single ordered file. This will perform slow if the dataset is big.

这篇关于如何导出配置单元中的视图数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆