FAQ
Repository: hive
Updated Branches:
   refs/heads/branch-1.2 ae10c832d -> e1b03dd46


HIVE-10481 - ACID table update finishes but values not really updated if column names are not all lower case (Eugene Koifman, reviewed by Alan Gates)


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

Branch: refs/heads/branch-1.2
Commit: e1b03dd4629ae61cfdde4634dff594dab6e46322
Parents: ae10c83
Author: Eugene Koifman <ekoifman@hortonworks.com>
Authored: Tue Apr 28 16:17:23 2015 -0700
Committer: Eugene Koifman <ekoifman@hortonworks.com>
Committed: Tue Apr 28 16:17:23 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/e1b03dd4/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/e1b03dd4/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<String> 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<String> 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<String> 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));

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedApr 28, '15 at 11:17p
activeApr 28, '15 at 11:17p
posts1
users1
websitehive.apache.org

1 user in discussion

Ekoifman: 1 post

People

Translate

site design / logo © 2021 Grokbase