Skip to content
Advertisement

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!

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement