Reply
New Contributor
Posts: 11
Registered: ‎05-15-2017
Accepted Solution

Override Hive Default Path

Hi Hive Users,

 

I have created a Hive database by overrrinding the defailt path as follows,

SQL:

Create database diff location '/user/cloudera/sat';

 

After creating this databse, I tried to access this path to see wether it's created a .db folder , but I don't see anything with this name there. Even I created a table in this database and I only see the new folder with name as test.

 

Not sure why its not crated diff.db folder in this path. Please refer the attached screen shots for more details. Please let me know if i am missing anything here.

 

Screen Shot 2017-06-04 at 9.32.57 AM.pngScreen Shot 2017-06-04 at 9.37.42 AM.pngScreen Shot 2017-06-04 at 9.38.27 AM.pngScreen Shot 2017-06-04 at 9.38.51 AM.png

New Contributor
Posts: 11
Registered: ‎05-15-2017

Re: Override Hive Default Path

Hi,

Could anyone please let me know on this? Thanks.

Highlighted
Posts: 137
Topics: 7
Kudos: 15
Solutions: 14
Registered: ‎07-16-2015

Re: Override Hive Default Path

[ Edited ]

Why do you expect to see a *.db folder if you don't specify it yourself ? This is not "how it works".

 

The following command sets the root dir of the database "diff" to "/user/cloudera/sat" :

 

Create database diff location '/user/cloudera/sat';

 This will not create a folder "diff.db" inside "sat".

 

If this is what you want then use the following command :

Create database diff location '/user/cloudera/sat/diff.db';

 

 

 

New Contributor
Posts: 11
Registered: ‎05-15-2017

Re: Override Hive Default Path

When I create a database without passing the location, then it will create that database in default location with <dbname>/db

ex:

hive> CREATE DATABASE Override1;
OK
Time taken: 0.06 seconds

it will create a Override1.db folder in the default path as

[cloudera@quickstart ~]$ hadoop fs -ls /user/hive/warehouse
Found 1item
drwxrwxrwx   - cloudera supergroup          0 2017-06-09 14:46 /user/hive/warehouse/override1.db
[cloudera@quickstart ~]$ 

why don't it it creates folder with <dbname>.db folder  when you pass the location to create a database(overriding the default path) ?

Posts: 137
Topics: 7
Kudos: 15
Solutions: 14
Registered: ‎07-16-2015

Re: Override Hive Default Path

[ Edited ]

>> why don't it it creates folder with <dbname>.db folder  when you pass the location to create a database(overriding the default path) ?

 

Because that is how hive works when you provide the path.

 

When you specify the path it uses this path. It's not adding a sub folder to the path you have provided.

It assumes you have provided the path you want to use exactly.

Announcements