在没有export+distcp+import的情况下对不同的配置单元集群执行简单hql后保存配置单元表

ig9co6j1  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(464)

我在集群x中有一个表a。
我想执行一些hql(比如 select * from A where A.country = 'INDIA' )将输出保存在集群y的表b中(&S)。
我可以对表a执行hql,并将数据存储在表temp中。然后,使用以下方法将此配置单元表导出到集群y中的表b:

EXPORT TABLE temp TO 'path/to/hdfs_clusterX';

hadoop distcp hdfs:///path/to/hdfs_clusterX hdfs:///path/to/hdfs_clusterY

IMPORT TABLE Y FROM 'path/to/another/hdfs

除了创建这个表,还有其他更好的方法吗?

sbtkgmzw

sbtkgmzw1#

选择*from a where a.country='印度';
将上面的select结果插入到其他表中,然后使用下面的命令将其导出到集群上的某个位置:假设表名为test
将表测试导出到“/path”;
之后,使用distcp命令将其移动到另一个集群
hadoop distcp源路径目标路径;

相关问题