hive不能在where子句中引用分区

bf1o4zei  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(307)

我创建了一个按日期划分的表。但不能在where子句中使用分区。以下是流程步骤1:

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。
有人知道原因吗?
谢谢

50pmv0ei

50pmv0ei1#

sahara,where子句中的分区起作用。有没有可能在 predicate 的rhs中指定了错误的值?
您可能还想查看其中的数据 /user/hive/warehouse/new_table (默认情况下)查看那里的数据是否与您期望的一样。

zzlelutf

zzlelutf2#

尝试插入

Insert overwrite table new_table partition (dt=$date)
    Select a, b, dt from my_table
    where dt = '$date'

相关问题