hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ekoif...@apache.org
Subject hive git commit: HIVE-15755 NullPointerException on invalid table name in ON clause of Merge statement (Eugene Koifman, reviewed by Wei Zheng)
Date Tue, 07 Feb 2017 18:11:39 GMT
Repository: hive
Updated Branches:
  refs/heads/master 3c230a62d -> 3ed7dc2b8


HIVE-15755 NullPointerException on invalid table name in ON clause of Merge statement (Eugene
Koifman, reviewed by Wei Zheng)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/3ed7dc2b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/3ed7dc2b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/3ed7dc2b

Branch: refs/heads/master
Commit: 3ed7dc2b82f84ade5f2be0cb85a95b49dc30086c
Parents: 3c230a6
Author: Eugene Koifman <ekoifman@hortonworks.com>
Authored: Tue Feb 7 10:11:35 2017 -0800
Committer: Eugene Koifman <ekoifman@hortonworks.com>
Committed: Tue Feb 7 10:11:35 2017 -0800

----------------------------------------------------------------------
 ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java         | 2 ++
 .../hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java  | 9 +++++++++
 ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java  | 9 +++++++++
 3 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/3ed7dc2b/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java b/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
index 6399dbe..6013218 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
@@ -247,6 +247,8 @@ public enum ErrorMsg {
   TRUNCATE_FOR_NON_MANAGED_TABLE(10146, "Cannot truncate non-managed table {0}.", true),
   TRUNCATE_FOR_NON_NATIVE_TABLE(10147, "Cannot truncate non-native table {0}.", true),
   PARTSPEC_FOR_NON_PARTITIONED_TABLE(10148, "Partition spec for non partitioned table {0}.",
true),
+  INVALID_TABLE_IN_ON_CLAUSE_OF_MERGE(10149, "No columns from target table ''{0}'' found
in ON " +
+    "clause ''{1}'' of MERGE statement.", true),
 
   LOAD_INTO_STORED_AS_DIR(10195, "A stored-as-directories table cannot be used as target
for LOAD"),
   ALTER_TBL_STOREDASDIR_NOT_SKEWED(10196, "This operation is only valid on skewed table."),

http://git-wip-us.apache.org/repos/asf/hive/blob/3ed7dc2b/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
b/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
index f102786..e798328 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
@@ -1205,6 +1205,15 @@ public class UpdateDeleteSemanticAnalyzer extends SemanticAnalyzer
{
     private String getPredicate() {
       //normilize table name for mapping
       List<String> targetCols = table2column.get(targetTableNameInSourceQuery.toLowerCase());
+      if(targetCols == null) {
+        /*e.g. ON source.t=1
+        * this is not strictly speaking invlaid but it does ensure that all columns from
target
+        * table are all NULL for every row.  This would make any WHEN MATCHED clause invalid
since
+        * we don't have a ROW__ID.  The WHEN NOT MATCHED could be meaningful but it's just
data from
+        * source satisfying source.t=1...  not worth the effort to support this*/
+        throw new IllegalArgumentException(ErrorMsg.INVALID_TABLE_IN_ON_CLAUSE_OF_MERGE
+          .format(targetTableNameInSourceQuery, onClauseAsString));
+      }
       StringBuilder sb = new StringBuilder();
       for(String col : targetCols) {
         if(sb.length() > 0) {

http://git-wip-us.apache.org/repos/asf/hive/blob/3ed7dc2b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
index a90dd35..c110089 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
@@ -842,4 +842,13 @@ public class TestTxnCommands {
     Assert.assertEquals(ErrorMsg.INVALID_TARGET_COLUMN_IN_SET_CLAUSE,
       ((HiveException)cpr.getException()).getCanonicalErrorMsg());
   }
+  @Test
+  public void testBadOnClause() throws Exception {
+    CommandProcessorResponse cpr = runStatementOnDriverNegative("merge into " + Table.ACIDTBL
+
+      " trgt using (select * from " + Table.NONACIDORCTBL +
+      "src) sub on sub.a = target.a when not matched then insert values (sub.a,sub.b)");
+    Assert.assertTrue("Error didn't match: " + cpr, cpr.getErrorMessage().contains(
+      "No columns from target table 'trgt' found in ON clause '`sub`.`a` = `target`.`a`'
of MERGE statement."));
+
+  }
 }


Mime
View raw message