[ 
https://issues.apache.org/jira/browse/HIVE-18670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

BELUGA BEHR updated HIVE-18670:
-------------------------------
    Description: 
A user is not able to drop a database if it has tables under it unless they 
include the _CASCADE_ keyword to their DROP DATABASE statement.

[https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DropTable]

I would like to propose that, if {{hive.mapred.mode}} is set to 'strict', Hive 
also checks for other data before dropping the database.

For example, if the database is stored within HDFS, then Hive should check if 
there exists other data, not even necessarily related to Hive, within the 
database's HDFS directory, before dropping.

The examples are:
{code:java|title=Example 1}
/hive/my_database
/hive/my_database/my_table

-- Does not succeed because 'my_table' exists
> DROP DATABASE my_database;

-- Succeeds and removes the root directory /hive/my_database
> DROP DATABASE my_database CASCADE;
{code}
{code:java|title=Example 2}
/hive/my_database
/hive/my_database/my_important_file.txt

-- Succeeds because no tables exist, but I just lost my "important" file
> DROP DATABASE my_database;
{code}

This "feature" is just to prevent people from shooting themselves in the foot, 
even if they shouldn't be using Hive space for storing unrelated data.

  was:
A user is not able to drop a database if it has tables under it unless they 
include the _CASCADE_ keyword to their DROP DATABASE statement.

[https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DropTable]

I would like to propose that, if {{hive.mapred.mode}} is set to 'strict', Hive 
also checks for other data before dropping the database.

For example, if the database is stored within HDFS, then Hive should check if 
there exists other data, not even necessarily related to Hive, within the 
database's HDFS directory, before dropping.

The examples are:
{code:java|title=Example 1}
/hive/my_database
/hive/my_database/my_table

-- Does not succeed because 'my_table' exists
> DROP DATABASE my_database;

-- Succeeds and removes the root directory /hive/my_database
> DROP DATABASE my_database CASCADE;
{code}
{code:java|title=Example 2}
/hive/my_database
/hive/my_database/my_important_file.txt

-- Succeeds because no tables exist, but I just lost my "important" file
> DROP DATABASE my_database;
{code}


> Prevent DROP DATABASE If Other Data Exists
> ------------------------------------------
>
>                 Key: HIVE-18670
>                 URL: https://issues.apache.org/jira/browse/HIVE-18670
>             Project: Hive
>          Issue Type: Improvement
>          Components: HiveServer2
>    Affects Versions: 3.0.0, 2.3.2
>            Reporter: BELUGA BEHR
>            Priority: Major
>
> A user is not able to drop a database if it has tables under it unless they 
> include the _CASCADE_ keyword to their DROP DATABASE statement.
> [https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DropTable]
> I would like to propose that, if {{hive.mapred.mode}} is set to 'strict', 
> Hive also checks for other data before dropping the database.
> For example, if the database is stored within HDFS, then Hive should check if 
> there exists other data, not even necessarily related to Hive, within the 
> database's HDFS directory, before dropping.
> The examples are:
> {code:java|title=Example 1}
> /hive/my_database
> /hive/my_database/my_table
> -- Does not succeed because 'my_table' exists
> > DROP DATABASE my_database;
> -- Succeeds and removes the root directory /hive/my_database
> > DROP DATABASE my_database CASCADE;
> {code}
> {code:java|title=Example 2}
> /hive/my_database
> /hive/my_database/my_important_file.txt
> -- Succeeds because no tables exist, but I just lost my "important" file
> > DROP DATABASE my_database;
> {code}
> This "feature" is just to prevent people from shooting themselves in the 
> foot, even if they shouldn't be using Hive space for storing unrelated data.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to