OFFLINE – Offline The Table Partition in Hive

In the previous post, we looked at how to take a table offline in Hive to avoid being queried. In this post, we’ll look at how to take a specific table partition offline to prevent it from being displayed.

Let’s look at how to alter a Hive table so that its partition data isn’t queried:

Pre-requisits:
Create the partitioned table as specified here.

Syntax:
ALTER TABLE t1 PARTITION (PARTITION_SPEC) ENABLE OFFLINE;

Example:
Hive> ALTER TABLE TownsList_Dynamic PARTITION (country=’England’) ENABLE OFFLINE;
Now, let’s issue the SELECT statement.

Hive> select * from TownsList_Dynamic where country=’England’
Now, this returns the error as we expected.
FAILED: SemanticException [Error 10113]: Query against an offline table or partition Table townslist_dynamic Partition country=England

Bringing back the table to ONLINE.
Hive> ALTER TABLE TownsList_Dynamic PARTITION (country=’England’) DISABLE OFFLINE;

Partition Offline Hive

Hope you find this article helpful.

Please subscribe for more interesting updates.

 

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s