OFFLINE – Offline The Table in Hive

There’s a functionality in Apache Hive that allows you to take the table offline. We won’t be able to query the table because of it. In other words, by offlining a table, we can restrict it from being queried. This, however, does not prevent another table from accessing the same data.

Let’s look at how to change a table in Hive to prevent it from being queried in practice:

Syntax:
ALTER TABLE <tablename> ENABLE OFFLINE;

Example:
Hive> ALTER TABLE emp ENABLE OFFLINE;
Now, let’s issue the SELECT statement.

Hive> SELECT * FROM emp;
Now, this returns the error as we expected.
FAILED: SemanticException [Error 10113]: Query against an offline table or partition Table emp

Bringing back the table to ONLINE.
Hive> ALTER TABLE emp DISABLE OFFLINE;

Table Offline in 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