如何创建没有任何中间文件的配置单元表? [英] How do I create a hive table without any intermediate files?

查看:106
本文介绍了如何创建没有任何中间文件的配置单元表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



具体来说,我有

pre> set idlist =(1,2,3);
设定值=(2,3,5);

我想创建一个有9行的表:

  id值
1 2
1 3
1 5
2 2
2 3
2 5
3 2
3 3
3 5

我不想 写一个 csv 文件并加载到配置单元中。



使用案例:
$ b


  1. 迭代
  2. 为SO问题创建小样本


解决方案

  create table my_table(id int,value int); 

插入覆盖表my_table
选择a.id作为id,b.value作为从(
的值)select count(*)from my_table $ b $ t
横向视图爆炸(数组(1,2,3))a作为id
横向视图爆炸(数组(2,3,5))b作为值;


I want to create and populate a hive table without loading anything from disk.

Specifically, I have

set idlist = (1,2,3);
set values = (2,3,5);

I want to create a table with 9 rows:

id value
1  2
1  3
1  5
2  2
2  3
2  5
3  2
3  3
3  5

Again, I do not want to write a csv file and load it into hive.

Use cases:

  1. iteration
  2. creating small test samples for SO questions

解决方案

create table my_table(id int, value int);

insert overwrite table my_table
select a.id as id, b.value as value from (
  select count(*) from my_table
) t
lateral view explode(array(1,2,3)) a as id
lateral view explode(array(2,3,5)) b as value;

这篇关于如何创建没有任何中间文件的配置单元表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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