commit b22a61a336e5edb092903d93476dc6be57824ac9 Author: Alice Fan Date: Mon Jul 9 21:55:16 2018 -0700 HIVE-19933 : ALTER TABLE DROP PARTITION - Partition Not Found diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index d8346bb459..09a24bdb0f 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -612,9 +612,6 @@ private static void populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal LOCALMODEMAXINPUTFILES("hive.exec.mode.local.auto.input.files.max", 4, "When hive.exec.mode.local.auto is true, the number of tasks should less than this for local mode."), - DROPIGNORESNONEXISTENT("hive.exec.drop.ignorenonexistent", true, - "Do not report an error if DROP TABLE/VIEW/Index/Function specifies a non-existent table/view/function"), - HIVEIGNOREMAPJOINHINT("hive.ignore.mapjoin.hint", true, "Ignore the mapjoin hint"), HIVE_FILE_MAX_FOOTER("hive.file.max.footer", 100, @@ -5335,7 +5332,6 @@ public ZoneId getLocalTimeZone() { ConfVars.BYTESPERREDUCER.varname, ConfVars.CLIENT_STATS_COUNTERS.varname, ConfVars.DEFAULTPARTITIONNAME.varname, - ConfVars.DROPIGNORESNONEXISTENT.varname, ConfVars.HIVECOUNTERGROUP.varname, ConfVars.HIVEDEFAULTMANAGEDFILEFORMAT.varname, ConfVars.HIVEENFORCEBUCKETMAPJOIN.varname, diff --git a/hcatalog/src/test/e2e/hcatalog/tests/hcat.conf b/hcatalog/src/test/e2e/hcatalog/tests/hcat.conf index 411b7d3008..22c175a111 100644 --- a/hcatalog/src/test/e2e/hcatalog/tests/hcat.conf +++ b/hcatalog/src/test/e2e/hcatalog/tests/hcat.conf @@ -304,9 +304,7 @@ show partitions hcat_altertable_7;\, 'num' => 12 ,'depends_on' => 'HCat_AlterTable_11' ,'hcat' => q\ -set hive.exec.drop.ignorenonexistent = false; alter table hcat_altertable_7 drop if exists partition (grade='8',section='a'), partition(grade='7',section='d'), partition(grade='7',section='c'); -set hive.exec.drop.ignorenonexistent = true; show partitions hcat_altertable_7;\, ,'expected_out_regex' => 'grade=7/section=a(\s)*grade=7/section=b' ,'rc' => 0 @@ -407,7 +405,7 @@ show tables; describe hcat_view_1_1; describe hcat_view_1_2; drop view hcat_view_1_1; -drop view hcat_view_1_3;" +drop view if exists hcat_view_1_3;" ,'rc' => 0 }, { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java index 9ad46895a5..93c217a87d 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java @@ -1425,8 +1425,7 @@ private void analyzeDropTable(ASTNode ast, TableType expectedType) boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null); // we want to signal an error if the table/view doesn't exist and we're // configured not to fail silently - boolean throwException = - !ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); + boolean throwException = !ifExists; ReplicationSpec replicationSpec = new ReplicationSpec(ast); @@ -3325,8 +3324,7 @@ private void analyzeAlterTableModifyCols(String[] qualified, ASTNode ast, private void analyzeAlterTableDropParts(String[] qualified, ASTNode ast, boolean expectView) throws SemanticException { - boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null) - || HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); + boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null); // If the drop has to fail on non-existent partitions, we cannot batch expressions. // That is because we actually have to check each separate expression for existence. // We could do a small optimization for the case where expr has all columns and all diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/FunctionSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/FunctionSemanticAnalyzer.java index 2cfcc6b611..bb93b85790 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/FunctionSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/FunctionSemanticAnalyzer.java @@ -97,8 +97,7 @@ private void analyzeDropFunction(ASTNode ast) throws SemanticException { boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null); // we want to signal an error if the function doesn't exist and we're // configured not to ignore this - boolean throwException = - !ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); + boolean throwException = !ifExists; FunctionInfo info = FunctionRegistry.getFunctionInfo(functionName); if (info == null) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/MacroSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/MacroSemanticAnalyzer.java index 88b6068941..b3d892824e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/MacroSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/MacroSemanticAnalyzer.java @@ -151,8 +151,7 @@ private void analyzeDropMacro(ASTNode ast) throws SemanticException { boolean ifExists = (ast.getFirstChildWithType(TOK_IFEXISTS) != null); // we want to signal an error if the function doesn't exist and we're // configured not to ignore this - boolean throwException = - !ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); + boolean throwException = !ifExists; // Temp macros are not allowed to have qualified names. if (FunctionUtils.isQualifiedFunctionName(functionName)) { diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestMacroSemanticAnalyzer.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestMacroSemanticAnalyzer.java index 0334cf2c76..21aaf35419 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestMacroSemanticAnalyzer.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestMacroSemanticAnalyzer.java @@ -60,12 +60,7 @@ private void analyze(ASTNode ast) throws Exception { } } @Test - public void testDropMacroDoesNotExist() throws Exception { - analyze(parse("DROP TEMPORARY MACRO SOME_MACRO")); - } - @Test public void testDropMacroExistsDoNotIgnoreErrors() throws Exception { - conf.setBoolVar(ConfVars.DROPIGNORESNONEXISTENT, false); FunctionRegistry.registerTemporaryUDF("SOME_MACRO", GenericUDFMacro.class); analyze(parse("DROP TEMPORARY MACRO SOME_MACRO")); } @@ -76,7 +71,6 @@ public void testDropMacro() throws Exception { } @Test(expected = SemanticException.class) public void testDropMacroNonExistent() throws Exception { - conf.setBoolVar(ConfVars.DROPIGNORESNONEXISTENT, false); analyze(parse("DROP TEMPORARY MACRO SOME_MACRO")); } @Test @@ -85,7 +79,6 @@ public void testDropMacroNonExistentWithIfExists() throws Exception { } @Test public void testDropMacroNonExistentWithIfExistsDoNotIgnoreNonExistent() throws Exception { - conf.setBoolVar(ConfVars.DROPIGNORESNONEXISTENT, false); analyze(parse("DROP TEMPORARY MACRO IF EXISTS SOME_MACRO")); } @Test diff --git a/ql/src/test/queries/clientnegative/drop_func_nonexistent.q b/ql/src/test/queries/clientnegative/drop_func_nonexistent.q index 892ef00e3f..0ca02dbe87 100644 --- a/ql/src/test/queries/clientnegative/drop_func_nonexistent.q +++ b/ql/src/test/queries/clientnegative/drop_func_nonexistent.q @@ -1,3 +1,2 @@ -set hive.exec.drop.ignorenonexistent=false; -- Can't use DROP FUNCTION if the function doesn't exist and IF EXISTS isn't specified drop function nonexistent_function; diff --git a/ql/src/test/queries/clientnegative/drop_function_failure.q b/ql/src/test/queries/clientnegative/drop_function_failure.q index 51dc5e9d8e..b470375c8d 100644 --- a/ql/src/test/queries/clientnegative/drop_function_failure.q +++ b/ql/src/test/queries/clientnegative/drop_function_failure.q @@ -1,3 +1,2 @@ -set hive.exec.drop.ignorenonexistent=false; -- Can't use DROP TEMPORARY FUNCTION if the function doesn't exist and IF EXISTS isn't specified DROP TEMPORARY FUNCTION UnknownFunction; diff --git a/ql/src/test/queries/clientnegative/drop_partition_failure.q b/ql/src/test/queries/clientnegative/drop_partition_failure.q index c2074f69cb..69864c4689 100644 --- a/ql/src/test/queries/clientnegative/drop_partition_failure.q +++ b/ql/src/test/queries/clientnegative/drop_partition_failure.q @@ -6,6 +6,5 @@ alter table mp add partition (b='2', c='2'); show partitions mp; -set hive.exec.drop.ignorenonexistent=false; -- Can't use DROP PARTITION if the partition doesn't exist and IF EXISTS isn't specified alter table mp drop partition (b='3'); diff --git a/ql/src/test/queries/clientnegative/drop_partition_filter_failure.q b/ql/src/test/queries/clientnegative/drop_partition_filter_failure.q index df476ed7c4..08d5eebd55 100644 --- a/ql/src/test/queries/clientnegative/drop_partition_filter_failure.q +++ b/ql/src/test/queries/clientnegative/drop_partition_filter_failure.q @@ -3,6 +3,5 @@ create table ptestfilter1 (a string, b int) partitioned by (c string, d string); alter table ptestfilter1 add partition (c='US', d=1); show partitions ptestfilter1; -set hive.exec.drop.ignorenonexistent=false; alter table ptestfilter1 drop partition (c='US', d<1); diff --git a/ql/src/test/queries/clientnegative/drop_table_failure1.q b/ql/src/test/queries/clientnegative/drop_table_failure1.q index d47c08b876..f7c5aabf2a 100644 --- a/ql/src/test/queries/clientnegative/drop_table_failure1.q +++ b/ql/src/test/queries/clientnegative/drop_table_failure1.q @@ -1,3 +1,2 @@ -set hive.exec.drop.ignorenonexistent=false; -- Can't use DROP TABLE if the table doesn't exist and IF EXISTS isn't specified DROP TABLE UnknownTable; diff --git a/ql/src/test/queries/clientnegative/drop_view_failure2.q b/ql/src/test/queries/clientnegative/drop_view_failure2.q index 93bb16232d..e14c292dc6 100644 --- a/ql/src/test/queries/clientnegative/drop_view_failure2.q +++ b/ql/src/test/queries/clientnegative/drop_view_failure2.q @@ -1,3 +1,2 @@ -SET hive.exec.drop.ignorenonexistent=false; -- Can't use DROP VIEW if the view doesn't exist and IF EXISTS isn't specified DROP VIEW UnknownView; diff --git a/ql/src/test/queries/clientpositive/create_view_partitioned.q b/ql/src/test/queries/clientpositive/create_view_partitioned.q index 691a0f5b02..8ebfc3f2be 100644 --- a/ql/src/test/queries/clientpositive/create_view_partitioned.q +++ b/ql/src/test/queries/clientpositive/create_view_partitioned.q @@ -1,8 +1,8 @@ --! qt:dataset:srcpart --! qt:dataset:src -DROP VIEW vp1; -DROP VIEW vp2; -DROP VIEW vp3; +DROP VIEW IF EXISTS vp1; +DROP VIEW IF EXISTS vp2; +DROP VIEW IF EXISTS vp3; -- test partitioned view definition -- (underlying table is not actually partitioned) @@ -39,8 +39,6 @@ SHOW TABLE EXTENDED LIKE vp1 PARTITION(value='val_86'); ALTER VIEW vp1 DROP PARTITION (value='val_xyz'); -SET hive.exec.drop.ignorenonexistent=false; - -- should work since we use IF EXISTS ALTER VIEW vp1 DROP IF EXISTS PARTITION (value='val_xyz'); diff --git a/ql/src/test/queries/clientpositive/drop_function.q b/ql/src/test/queries/clientpositive/drop_function.q index 18c428ce20..a6f7396ad6 100644 --- a/ql/src/test/queries/clientpositive/drop_function.q +++ b/ql/src/test/queries/clientpositive/drop_function.q @@ -1,2 +1 @@ -SET hive.exec.drop.ignorenonexistent=false; DROP TEMPORARY FUNCTION IF EXISTS UnknownFunction; diff --git a/ql/src/test/queries/clientpositive/drop_multi_partitions.q b/ql/src/test/queries/clientpositive/drop_multi_partitions.q index 65c60af782..33a3307fb6 100644 --- a/ql/src/test/queries/clientpositive/drop_multi_partitions.q +++ b/ql/src/test/queries/clientpositive/drop_multi_partitions.q @@ -13,7 +13,6 @@ alter table dmp.mp_n0 drop partition (b='1'); show partitions dmp.mp_n0; -set hive.exec.drop.ignorenonexistent=false; alter table dmp.mp_n0 drop if exists partition (b='3'); show partitions dmp.mp_n0; diff --git a/ql/src/test/queries/clientpositive/drop_partitions_filter.q b/ql/src/test/queries/clientpositive/drop_partitions_filter.q index 5862753b23..79b18125fe 100644 --- a/ql/src/test/queries/clientpositive/drop_partitions_filter.q +++ b/ql/src/test/queries/clientpositive/drop_partitions_filter.q @@ -28,7 +28,6 @@ show partitions ptestfilter_n1; alter table ptestfilter_n1 drop partition (c != 'France'); show partitions ptestfilter_n1; -set hive.exec.drop.ignorenonexistent=false; alter table ptestfilter_n1 drop if exists partition (c='US'); show partitions ptestfilter_n1; diff --git a/ql/src/test/queries/clientpositive/drop_table.q b/ql/src/test/queries/clientpositive/drop_table.q index 6d189fc43c..1148ed61f4 100644 --- a/ql/src/test/queries/clientpositive/drop_table.q +++ b/ql/src/test/queries/clientpositive/drop_table.q @@ -1,2 +1 @@ -SET hive.exec.drop.ignorenonexistent=false; DROP TABLE IF EXISTS UnknownTable; diff --git a/ql/src/test/queries/clientpositive/drop_view.q b/ql/src/test/queries/clientpositive/drop_view.q index 4ff097541e..4c354a7ac2 100644 --- a/ql/src/test/queries/clientpositive/drop_view.q +++ b/ql/src/test/queries/clientpositive/drop_view.q @@ -1,2 +1 @@ -SET hive.exec.drop.ignorenonexistent=false; DROP VIEW IF EXISTS UnknownView; diff --git a/ql/src/test/results/clientpositive/create_view_partitioned.q.out b/ql/src/test/results/clientpositive/create_view_partitioned.q.out index be1e19b8db..f40966be85 100644 --- a/ql/src/test/results/clientpositive/create_view_partitioned.q.out +++ b/ql/src/test/results/clientpositive/create_view_partitioned.q.out @@ -1,14 +1,14 @@ -PREHOOK: query: DROP VIEW vp1 +PREHOOK: query: DROP VIEW IF EXISTS vp1 PREHOOK: type: DROPVIEW -POSTHOOK: query: DROP VIEW vp1 +POSTHOOK: query: DROP VIEW IF EXISTS vp1 POSTHOOK: type: DROPVIEW -PREHOOK: query: DROP VIEW vp2 +PREHOOK: query: DROP VIEW IF EXISTS vp2 PREHOOK: type: DROPVIEW -POSTHOOK: query: DROP VIEW vp2 +POSTHOOK: query: DROP VIEW IF EXISTS vp2 POSTHOOK: type: DROPVIEW -PREHOOK: query: DROP VIEW vp3 +PREHOOK: query: DROP VIEW IF EXISTS vp3 PREHOOK: type: DROPVIEW -POSTHOOK: query: DROP VIEW vp3 +POSTHOOK: query: DROP VIEW IF EXISTS vp3 POSTHOOK: type: DROPVIEW PREHOOK: query: CREATE VIEW vp1 PARTITIONED ON (value)