HiveQL select 无法在带有分区的外部 table 上按预期工作
HiveQL select not working as expected on an external table with partitions
我在创建的自定义外部 table 上使用 select 语句时遇到问题。在使用添加分区命令为年月日创建 table 后,我已将分区添加到此 table。
我面临的问题是,对于这个 select 语句,我只得到一行,其中 day = 1,而我预计 5 天有 5 行。
select * from test_data where key = 'AX001';
对于这些陈述中的每一个,我都会得到一个结果。
select * from test_data where key = 'AX001' and day = 2;
select * from test_data where key = 'AX001' and day = 3;
但是为此我只得到一行,day = 2。
select * from test_data where key = 'AX001' and day in (2,3);
知道这种行为的原因是什么吗?
显然这里的解决方案 ,这是我已经解决的另一个问题
select * from test_table where key = 'AX001' and day in (1,2,3);
set hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat;
select * from test_table where key = 'AX001' and day in (1,2,3);
set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
select * from test_table where key = 'AX001' and day in (1,2,3);
只有最后一个给了我 3 results.The 前两个 returns 两行。
我在创建的自定义外部 table 上使用 select 语句时遇到问题。在使用添加分区命令为年月日创建 table 后,我已将分区添加到此 table。
我面临的问题是,对于这个 select 语句,我只得到一行,其中 day = 1,而我预计 5 天有 5 行。
select * from test_data where key = 'AX001';
对于这些陈述中的每一个,我都会得到一个结果。
select * from test_data where key = 'AX001' and day = 2;
select * from test_data where key = 'AX001' and day = 3;
但是为此我只得到一行,day = 2。
select * from test_data where key = 'AX001' and day in (2,3);
知道这种行为的原因是什么吗?
显然这里的解决方案
select * from test_table where key = 'AX001' and day in (1,2,3);
set hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat;
select * from test_table where key = 'AX001' and day in (1,2,3);
set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
select * from test_table where key = 'AX001' and day in (1,2,3);
只有最后一个给了我 3 results.The 前两个 returns 两行。