Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72A54105D7 for ; Tue, 28 Apr 2015 23:08:12 +0000 (UTC) Received: (qmail 62162 invoked by uid 500); 28 Apr 2015 23:08:12 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 62120 invoked by uid 500); 28 Apr 2015 23:08:12 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 62109 invoked by uid 99); 28 Apr 2015 23:08:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2015 23:08:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2206FE0913; Tue, 28 Apr 2015 23:08:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ekoifman@apache.org To: commits@hive.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hive git commit: HIVE-10481 - ACID table update finishes but values not really updated if column names are not all lower case Date: Tue, 28 Apr 2015 23:08:12 +0000 (UTC) Repository: hive Updated Branches: refs/heads/master cd027b7c5 -> 57fcbce52 HIVE-10481 - ACID table update finishes but values not really updated if column names are not all lower case Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/57fcbce5 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/57fcbce5 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/57fcbce5 Branch: refs/heads/master Commit: 57fcbce5251c04818dd0975f921c2648f289c8f8 Parents: cd027b7 Author: Eugene Koifman Authored: Tue Apr 28 16:07:44 2015 -0700 Committer: Eugene Koifman Committed: Tue Apr 28 16:07:44 2015 -0700 ---------------------------------------------------------------------- .../hive/ql/parse/UpdateDeleteSemanticAnalyzer.java | 13 +++++++++++-- .../org/apache/hadoop/hive/ql/TestTxnCommands2.java | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/57fcbce5/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 7af68de..4c69534 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 @@ -190,7 +190,7 @@ public class UpdateDeleteSemanticAnalyzer extends SemanticAnalyzer { addSetRCols((ASTNode) assignment.getChildren().get(1), setRCols); - String columnName = colName.getText(); + String columnName = normalizeColName(colName.getText()); // Make sure this isn't one of the partitioning columns, that's not supported. if (partCols != null) { @@ -397,11 +397,20 @@ public class UpdateDeleteSemanticAnalyzer extends SemanticAnalyzer { ASTNode colName = (ASTNode)node.getChildren().get(0); assert colName.getToken().getType() == HiveParser.Identifier : "Expected column name"; - setRCols.add(colName.getText()); + setRCols.add(normalizeColName(colName.getText())); } else if (node.getChildren() != null) { for (Node n : node.getChildren()) { addSetRCols((ASTNode)n, setRCols); } } } + + /** + * Column names are stored in metastore in lower case, regardless of the CREATE TABLE statement. + * Unfortunately there is no single place that normalizes the input query. + * @param colName not null + */ + private static String normalizeColName(String colName) { + return colName.toLowerCase(); + } } http://git-wip-us.apache.org/repos/asf/hive/blob/57fcbce5/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java index 06d2ca2..ac5ae2a 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java @@ -58,6 +58,7 @@ public class TestTxnCommands2 { @Before public void setUp() throws Exception { + tearDown(); hiveConf = new HiveConf(this.getClass()); hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, ""); hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, ""); @@ -108,6 +109,19 @@ public class TestTxnCommands2 { List rs1 = runStatementOnDriver("select a,b from " + Table.NONACIDORCTBL); } @Test + public void testUpdateMixedCase() throws Exception { + int[][] tableData = {{1,2},{3,3},{5,3}}; + runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData)); + runStatementOnDriver("update " + Table.ACIDTBL + " set B = 7 where A=1"); + List rs = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " order by a,b"); + int[][] updatedData = {{1,7},{3,3},{5,3}}; + Assert.assertEquals("Update failed", stringifyValues(updatedData), rs); + runStatementOnDriver("update " + Table.ACIDTBL + " set B = B + 1 where A=1"); + List rs2 = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " order by a,b"); + int[][] updatedData2 = {{1,8},{3,3},{5,3}}; + Assert.assertEquals("Update failed", stringifyValues(updatedData2), rs2); + } + @Test public void testDeleteIn() throws Exception { int[][] tableData = {{1,2},{3,2},{5,2},{1,3},{3,3},{5,3}}; runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData));