diff --git ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java index d3be11a30a..37cadf02ad 100644 --- ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java +++ ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java @@ -122,6 +122,11 @@ public void run() { txnHandler.markCleaned(ci); continue; } + if (t.isPartitioned() && ci.partName == null) { + LOG.error("The table is partitioned but partition name is not specified for the request."); + txnHandler.markCleaned(ci); + continue; + } } catch (Exception e) { txnHandler.markCleaned(ci); continue; diff --git ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java index 3737b6a4d5..7955f5b12d 100644 --- ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java +++ ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java @@ -923,8 +923,12 @@ public void updateDeletePartitioned() throws Exception { int[][] tableData = {{1,2},{3,4},{5,6}}; runStatementOnDriver("insert into " + Table.ACIDTBLPART + " partition(p=1) (a,b) " + makeValuesClause(tableData)); runStatementOnDriver("insert into " + Table.ACIDTBLPART + " partition(p=2) (a,b) " + makeValuesClause(tableData)); + TxnStore txnHandler = TxnUtils.getTxnStore(hiveConf); - txnHandler.compact(new CompactionRequest("default", Table.ACIDTBLPART.name(), CompactionType.MAJOR)); + CompactionRequest rqst = new CompactionRequest("default", Table.ACIDTBLPART.name(), CompactionType.MAJOR); + rqst.setPartitionname("p=1, p=2"); + txnHandler.compact(rqst); + runWorker(hiveConf); runCleaner(hiveConf); runStatementOnDriver("update " + Table.ACIDTBLPART + " set b = b + 1 where a = 3"); diff --git standalone-metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java standalone-metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java index 800219fe89..cebf8c6c75 100644 --- standalone-metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java +++ standalone-metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java @@ -532,6 +532,14 @@ public void setPartitionKeysIsSet(boolean value) { } } + public boolean isPartitioned() { + if (this.partitionKeys != null && this.partitionKeys.size() != 0) { + return true; + } else { + return false; + } + } + public int getParametersSize() { return (this.parameters == null) ? 0 : this.parameters.size(); }