No partition predicate found for Alias even when the partition predicate in present in the query

33,309

Solution 1

This happens because hive is set to strict mode. this allow the partition table to access the respective partition /folder in hdfs .

  set hive.mapred.mode=unstrict;  it will work 

Solution 2

In your query error it is said: No partition predicate found for Alias "inv" Table "pos_inv".

So you must put the where clause for the fields of the partitioned table (for pos_inv), and not for the other one (inv), as you've done.

Solution 3

set hive.mapred.mode=unstrict allows you access the whole data rather than the particular partitons. In some case read whole dataset is necessary, such as: rank() over

Share:
33,309
jeff
Author by

jeff

Updated on July 05, 2022

Comments

  • jeff
    jeff almost 2 years

    I have a table pos.pos_inv in hdfs which is partitioned by yyyymm. Below is the query:

    select DATE_ADD(to_date(from_unixtime(unix_timestamp(Inv.actvydt, 'MM/dd/yyyy'))),5), 
           to_date(from_unixtime(unix_timestamp(Inv.actvydt, 'MM/dd/yyyy'))),yyyymm 
       from pos.pos_inv inv 
          INNER JOIN pos.POSActvyBrdg Brdg ON Brdg.EIS_POSActvyBrdgId = Inv.EIS_POSActvyBrdgId 
          where to_date(from_unixtime(unix_timestamp(Inv.nrmlzdwkenddt, 'MM/dd/yyyy'))) 
           BETWEEN DATE_SUB(to_date(from_unixtime(unix_timestamp(Inv.actvydt, 'MM/dd/yyyy'))),6) 
            and DATE_ADD(to_date(from_unixtime(unix_timestamp(Inv.actvydt, 'MM/dd/yyyy'))),6) 
            and inv.yyyymm=201501
    

    I have provided the partition value for the query as 201501, but still i get the error"

     Error while compiling statement: FAILED: SemanticException [Error 10041]: No partition predicate found for Alias "inv" Table "pos_inv"
    

    (schema)The partition, yyyymm is int type and actvydt is date stored as string type.

  • om471987
    om471987 about 6 years
    -1 this is not the correct use. You should filter your select statement with appropriate predicate. For, example. if table has one predicate named 'dt' then Select * from MyTable where dt='2017/10/10'