sqlhadoophivehive-configuration

How to prevent sql without limit in Hive?


Many users are used to using 'select * from tables' in oracle/mysql

But i should not allow them to query like that in hive

Is there any way to prevent a full_table scan in hive?

Like trigger or somethng else?

Thanks a lot!


Solution

  • To prevent full table scan use these settings.

    set hive.mapred.mode=strict;  --prevent full scan
    SET hive.limit.query.max.table.partition=10; --limit partitions to 10
    

    Hive will generate exception if partition predicate is not specified:

    FAILED: SemanticException [Error 10041]: No partition predicate found
    

    And exception example in case the number of partitions exceeded:

    SemanticException Number of partitions scanned (=37) on table