【发布时间】:2012-12-17 16:46:49
【问题描述】:
我创建了一个按日期分区的表。但不能在 where 子句中使用分区。 这是过程 第一步:
CREATE TABLE new_table (
a string,
b string
)
PARTITIONED BY (dt string);
第二步:
Insert overwrite table new_table partition (dt=$date)
Select a, b from my_table
where dt = '$date
表已创建。
Describe new_table;
a string
b string
dt string
问题:
select * from new_table where dt='$date'
返回空集。
而
select * from new_table
返回 a、b 和 dt。
有谁知道这可能是什么原因?
谢谢
【问题讨论】:
-
如果你运行
SHOW PARTITIONS new_table;会发生什么? -
试过了,但无法重现您的问题;做了几个排列,包括动态分区。如前所述,验证您的查询、检查分区等。
-
我的错,我在做; > hive -e 'select * from new_table where dt='$date'' 和单引号导致问题。我花了 3 个小时才看到这个:) 谢谢你的回答