Venkatesan Muniappan
Venkatesan Muniappan

Reputation: 447

Creating Hive View - Turn off metadata lookup from Hive Metastore

Is it possible to create a hive view on top of a nonexistent hive table or views?. This ability will help us deploy the hive DDL without any order at the time of refresh (migrating tables or views from one environment to another). In our environment, we have views built on top of another view. If we deploy them in any order, with the default setup some of the views may fail saying the underlying table/view doesn't exist. Looking to see if we can turn off the metadata lookup from hive metastore so that the type checks are not done at the time of view creation. It can be enforced after the deployment or at the time of querying the view for data retrieval because by that time all the views/tables will be completely deployed and there won't be any type checking related errors.

I checked on the internet for pointers but I couldn't find any. Any suggestions in this regard will be helpful to us.

Thanks in advance.

Upvotes: 1

Views: 231

Answers (1)

leftjoin
leftjoin

Reputation: 38335

Add IF NOT EXISTS to all create statements and run all several times until errors disappear.

If executed 2 times in the wrong order like this, second run will succeed without any error:

drop view if exists my_view;
create view if not exists my_view as select from table1; --fails first time, succeeds on second run
drop table if exists table1;
create table if not exists table1(id int);

Upvotes: 1

Related Questions