FAQ
Author: gates
Date: Tue Sep 23 15:02:59 2014
New Revision: 1627048

URL: http://svn.apache.org/r1627048
Log:
HIVE-8152 Update with expression in set fails (Eugene Koifman, reviewed by Alan Gates)

Modified:
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/FromClauseParser.g
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
     hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java
     hive/trunk/ql/src/test/queries/clientpositive/insert_values_tmp_table.q
     hive/trunk/ql/src/test/queries/clientpositive/update_all_types.q
     hive/trunk/ql/src/test/results/clientpositive/insert_values_tmp_table.q.out
     hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_tmp_table.q.out
     hive/trunk/ql/src/test/results/clientpositive/tez/update_all_types.q.out
     hive/trunk/ql/src/test/results/clientpositive/update_all_types.q.out

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/FromClauseParser.g
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/FromClauseParser.g?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/FromClauseParser.g (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/FromClauseParser.g Tue Sep 23 15:02:59 2014
@@ -263,7 +263,7 @@ searchCondition
  // INSERT INTO <table> (col1,col2,...) SELECT * FROM (VALUES(1,2,3),(4,5,6),...) as Foo(a,b,c)
  valueRowConstructor
      :
- LPAREN atomExpression (COMMA atomExpression)* RPAREN -> ^(TOK_VALUE_ROW atomExpression+)
+ LPAREN precedenceUnaryPrefixExpression (COMMA precedenceUnaryPrefixExpression)* RPAREN -> ^(TOK_VALUE_ROW precedenceUnaryPrefixExpression+)
      ;

  valuesTableConstructor

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g Tue Sep 23 15:02:59 2014
@@ -2238,7 +2238,7 @@ deleteStatement
  /*SET <columName> = (3 + col2)*/
  columnAssignmentClause
     :
- tableOrColumn EQUAL^ atomExpression
+ tableOrColumn EQUAL^ precedencePlusExpression
     ;

  /*SET col1 = 5, col2 = (4 + col4), ...*/

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java Tue Sep 23 15:02:59 2014
@@ -343,8 +343,10 @@ public class UpdateDeleteSemanticAnalyze

        // Add the setRCols to the input list
        for (String colName : setRCols) {
- columnAccessInfo.add(Table.getCompleteName(mTable.getDbName(), mTable.getTableName()),
+ if(columnAccessInfo != null) {//assuming this means we are not doing Auth
+ columnAccessInfo.add(Table.getCompleteName(mTable.getDbName(), mTable.getTableName()),
              colName);
+ }
        }
      }

@@ -386,7 +388,7 @@ public class UpdateDeleteSemanticAnalyze
        setRCols.add(colName.getText());
      } else if (node.getChildren() != null) {
        for (Node n : node.getChildren()) {
- addSetRCols(node, setRCols);
+ addSetRCols((ASTNode)n, setRCols);
        }
      }
    }

Modified: hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java (original)
+++ hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java Tue Sep 23 15:02:59 2014
@@ -24,6 +24,9 @@ import org.junit.Before;
  import org.junit.BeforeClass;
  import org.junit.Test;

+/**
+ * various Parser tests for INSERT/UPDATE/DELETE
+ */
  public class TestIUD {
    private static HiveConf conf;

@@ -102,6 +105,18 @@ public class TestIUD {
        ast.toStringTree());
    }
    @Test
+ public void testUpdateWithWhereSingleSetExpr() throws ParseException {
+ ASTNode ast = parse("UPDATE src SET key = -3+(5*9)%8, val = cast(6.1 + c as INT), d = d - 1 WHERE value IS NULL");
+ Assert.assertEquals("AST doesn't match",
+ "(TOK_UPDATE_TABLE (TOK_TABNAME src) " +
+ "(TOK_SET_COLUMNS_CLAUSE " +
+ "(= (TOK_TABLE_OR_COL key) (+ (- 3) (% (* 5 9) 8))) " +
+ "(= (TOK_TABLE_OR_COL val) (TOK_FUNCTION TOK_INT (+ 6.1 (TOK_TABLE_OR_COL c)))) " +
+ "(= (TOK_TABLE_OR_COL d) (- (TOK_TABLE_OR_COL d) 1))) " +
+ "(TOK_WHERE (TOK_FUNCTION TOK_ISNULL (TOK_TABLE_OR_COL value))))",
+ ast.toStringTree());
+ }
+ @Test
    public void testUpdateWithWhereMultiSet() throws ParseException {
      ASTNode ast = parse("UPDATE src SET key = 3, value = 8 WHERE VALUE = 1230997");
      Assert.assertEquals("AST doesn't match",
@@ -207,13 +222,13 @@ public class TestIUD {
    }
    @Test
    public void testInsertIntoTableFromAnonymousTable() throws ParseException {
- ASTNode ast = parse("insert into table page_view values(1,2),(3,4)");
+ ASTNode ast = parse("insert into table page_view values(-1,2),(3,+4)");
      Assert.assertEquals("AST doesn't match",
        "(TOK_QUERY " +
          "(TOK_FROM " +
            "(TOK_VIRTUAL_TABLE " +
            "(TOK_VIRTUAL_TABREF TOK_ANONYMOUS) " +
- "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2) (TOK_VALUE_ROW 3 4)))) " +
+ "(TOK_VALUES_TABLE (TOK_VALUE_ROW (- 1) 2) (TOK_VALUE_ROW 3 (+ 4))))) " +
          "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view))) " +
            "(TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))",
        ast.toStringTree());

Modified: hive/trunk/ql/src/test/queries/clientpositive/insert_values_tmp_table.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/insert_values_tmp_table.q?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/insert_values_tmp_table.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/insert_values_tmp_table.q Tue Sep 23 15:02:59 2014
@@ -7,6 +7,7 @@ create temporary table acid_ivtt(i int,

  insert into table acid_ivtt values
      (1, 109.23, 'mary had a little lamb'),
- (429496729, 0.14, 'its fleece was white as snow');
+ (429496729, 0.14, 'its fleece was white as snow'),
+ (-29496729, -0.14, 'negative values test');

  select i, de, vc from acid_ivtt order by i;

Modified: hive/trunk/ql/src/test/queries/clientpositive/update_all_types.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/update_all_types.q?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/update_all_types.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/update_all_types.q Tue Sep 23 15:02:59 2014
@@ -53,4 +53,11 @@ update acid_uat set

  select * from acid_uat order by i;

+update acid_uat set
+ ti = ti * 2,
+ si = cast(f as int),
+ d = floor(de)
+ where s = 'aw724t8c5558x2xneC624';

+
+select * from acid_uat order by i;

Modified: hive/trunk/ql/src/test/results/clientpositive/insert_values_tmp_table.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/insert_values_tmp_table.q.out?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/insert_values_tmp_table.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/insert_values_tmp_table.q.out Tue Sep 23 15:02:59 2014
@@ -8,13 +8,15 @@ POSTHOOK: Output: database:default
  POSTHOOK: Output: default@acid_ivtt
  PREHOOK: query: insert into table acid_ivtt values
      (1, 109.23, 'mary had a little lamb'),
- (429496729, 0.14, 'its fleece was white as snow')
+ (429496729, 0.14, 'its fleece was white as snow'),
+ (-29496729, -0.14, 'negative values test')
  PREHOOK: type: QUERY
  PREHOOK: Input: default@values__tmp__table__1
  PREHOOK: Output: default@acid_ivtt
  POSTHOOK: query: insert into table acid_ivtt values
      (1, 109.23, 'mary had a little lamb'),
- (429496729, 0.14, 'its fleece was white as snow')
+ (429496729, 0.14, 'its fleece was white as snow'),
+ (-29496729, -0.14, 'negative values test')
  POSTHOOK: type: QUERY
  POSTHOOK: Input: default@values__tmp__table__1
  POSTHOOK: Output: default@acid_ivtt
@@ -29,5 +31,6 @@ POSTHOOK: query: select i, de, vc from a
  POSTHOOK: type: QUERY
  POSTHOOK: Input: default@acid_ivtt
  #### A masked pattern was here ####
+-29496729 -0.14 negative values test
  1 109.23 mary had a little lamb
  429496729 0.14 its fleece was white as snow

Modified: hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_tmp_table.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_tmp_table.q.out?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_tmp_table.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_tmp_table.q.out Tue Sep 23 15:02:59 2014
@@ -8,13 +8,15 @@ POSTHOOK: Output: database:default
  POSTHOOK: Output: default@acid_ivtt
  PREHOOK: query: insert into table acid_ivtt values
      (1, 109.23, 'mary had a little lamb'),
- (429496729, 0.14, 'its fleece was white as snow')
+ (429496729, 0.14, 'its fleece was white as snow'),
+ (-29496729, -0.14, 'negative values test')
  PREHOOK: type: QUERY
  PREHOOK: Input: default@values__tmp__table__1
  PREHOOK: Output: default@acid_ivtt
  POSTHOOK: query: insert into table acid_ivtt values
      (1, 109.23, 'mary had a little lamb'),
- (429496729, 0.14, 'its fleece was white as snow')
+ (429496729, 0.14, 'its fleece was white as snow'),
+ (-29496729, -0.14, 'negative values test')
  POSTHOOK: type: QUERY
  POSTHOOK: Input: default@values__tmp__table__1
  POSTHOOK: Output: default@acid_ivtt
@@ -29,5 +31,6 @@ POSTHOOK: query: select i, de, vc from a
  POSTHOOK: type: QUERY
  POSTHOOK: Input: default@acid_ivtt
  #### A masked pattern was here ####
+-29496729 -0.14 negative values test
  1 109.23 mary had a little lamb
  429496729 0.14 its fleece was white as snow

Modified: hive/trunk/ql/src/test/results/clientpositive/tez/update_all_types.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/tez/update_all_types.q.out?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/tez/update_all_types.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/tez/update_all_types.q.out Tue Sep 23 15:02:59 2014
@@ -151,3 +151,37 @@ NULL -5470 -1072076362 1864027286 NULL -
  NULL -947 -1070551679 1864027286 NULL -947.0 NULL NULL 1970-01-01 iUR3Q iUR3Q 4KWs6gw7lv2WYd66P false
  11 NULL -1069736047 -453772520 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL k17Am8uPHWk02cEf1jet k17Am8uPHWk02cEf1jet qrXLLNX1 true
  1 2 3 4 3.14 6.28 5.99 NULL 2014-09-01 its a beautiful day in the neighbhorhood a beautiful day for a neighbor wont you be mine true
+PREHOOK: query: update acid_uat set
+ ti = ti * 2,
+ si = cast(f as int),
+ d = floor(de)
+ where s = 'aw724t8c5558x2xneC624'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@acid_uat
+PREHOOK: Output: default@acid_uat
+POSTHOOK: query: update acid_uat set
+ ti = ti * 2,
+ si = cast(f as int),
+ d = floor(de)
+ where s = 'aw724t8c5558x2xneC624'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@acid_uat
+POSTHOOK: Output: default@acid_uat
+PREHOOK: query: select * from acid_uat order by i
+PREHOOK: type: QUERY
+PREHOOK: Input: default@acid_uat
+#### A masked pattern was here ####
+POSTHOOK: query: select * from acid_uat order by i
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@acid_uat
+#### A masked pattern was here ####
+11 NULL -1073279343 -1595604468 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL oj1YrV5Wa oj1YrV5Wa P76636jJ6qM17d7DIy true
+NULL -7382 -1073051226 -1887561756 NULL -7382.0 NULL NULL 1970-01-01 A34p7oRr2WvUJNf A34p7oRr2WvUJNf 4hA4KQj2vD3fI6gX82220d false
+11 NULL -1072910839 2048385991 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL 0iqrc5 0iqrc5 KbaDXiN85adbHRx58v false
+NULL 8373 -1072081801 1864027286 NULL 8373.0 NULL NULL 1970-01-01 dPkN74F7 dPkN74F7 4KWs6gw7lv2WYd66P true
+NULL -5470 -1072076362 1864027286 NULL -5470.0 NULL NULL 1970-01-01 2uLyD28144vklju213J1mr 2uLyD28144vklju213J1mr 4KWs6gw7lv2WYd66P true
+-102 -51 -1071480828 -1401575336 -51.0 -51.0 -51.0 1969-12-31 16:00:08.451 NULL aw724t8c5558x2xneC624 aw724t8c5558x2xneC624 4uE7l74tESBiKfu7c8wM7GA true
+8 NULL -1071363017 1349676361 8.0 NULL 8.0 1969-12-31 16:00:15.892 NULL Anj0oF Anj0oF IwE1G7Qb0B1NEfV030g true
+NULL -947 -1070551679 1864027286 NULL -947.0 NULL NULL 1970-01-01 iUR3Q iUR3Q 4KWs6gw7lv2WYd66P false
+11 NULL -1069736047 -453772520 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL k17Am8uPHWk02cEf1jet k17Am8uPHWk02cEf1jet qrXLLNX1 true
+1 2 3 4 3.14 6.28 5.99 NULL 2014-09-01 its a beautiful day in the neighbhorhood a beautiful day for a neighbor wont you be mine true

Modified: hive/trunk/ql/src/test/results/clientpositive/update_all_types.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/update_all_types.q.out?rev=1627048&r1=1627047&r2=1627048&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/update_all_types.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/update_all_types.q.out Tue Sep 23 15:02:59 2014
@@ -151,3 +151,37 @@ NULL -5470 -1072076362 1864027286 NULL -
  NULL -947 -1070551679 1864027286 NULL -947.0 NULL NULL 1970-01-01 iUR3Q iUR3Q 4KWs6gw7lv2WYd66P false
  11 NULL -1069736047 -453772520 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL k17Am8uPHWk02cEf1jet k17Am8uPHWk02cEf1jet qrXLLNX1 true
  1 2 3 4 3.14 6.28 5.99 NULL 2014-09-01 its a beautiful day in the neighbhorhood a beautiful day for a neighbor wont you be mine true
+PREHOOK: query: update acid_uat set
+ ti = ti * 2,
+ si = cast(f as int),
+ d = floor(de)
+ where s = 'aw724t8c5558x2xneC624'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@acid_uat
+PREHOOK: Output: default@acid_uat
+POSTHOOK: query: update acid_uat set
+ ti = ti * 2,
+ si = cast(f as int),
+ d = floor(de)
+ where s = 'aw724t8c5558x2xneC624'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@acid_uat
+POSTHOOK: Output: default@acid_uat
+PREHOOK: query: select * from acid_uat order by i
+PREHOOK: type: QUERY
+PREHOOK: Input: default@acid_uat
+#### A masked pattern was here ####
+POSTHOOK: query: select * from acid_uat order by i
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@acid_uat
+#### A masked pattern was here ####
+11 NULL -1073279343 -1595604468 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL oj1YrV5Wa oj1YrV5Wa P76636jJ6qM17d7DIy true
+NULL -7382 -1073051226 -1887561756 NULL -7382.0 NULL NULL 1970-01-01 A34p7oRr2WvUJNf A34p7oRr2WvUJNf 4hA4KQj2vD3fI6gX82220d false
+11 NULL -1072910839 2048385991 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL 0iqrc5 0iqrc5 KbaDXiN85adbHRx58v false
+NULL 8373 -1072081801 1864027286 NULL 8373.0 NULL NULL 1970-01-01 dPkN74F7 dPkN74F7 4KWs6gw7lv2WYd66P true
+NULL -5470 -1072076362 1864027286 NULL -5470.0 NULL NULL 1970-01-01 2uLyD28144vklju213J1mr 2uLyD28144vklju213J1mr 4KWs6gw7lv2WYd66P true
+-102 -51 -1071480828 -1401575336 -51.0 -51.0 -51.0 1969-12-31 16:00:08.451 NULL aw724t8c5558x2xneC624 aw724t8c5558x2xneC624 4uE7l74tESBiKfu7c8wM7GA true
+8 NULL -1071363017 1349676361 8.0 NULL 8.0 1969-12-31 16:00:15.892 NULL Anj0oF Anj0oF IwE1G7Qb0B1NEfV030g true
+NULL -947 -1070551679 1864027286 NULL -947.0 NULL NULL 1970-01-01 iUR3Q iUR3Q 4KWs6gw7lv2WYd66P false
+11 NULL -1069736047 -453772520 11.0 NULL 11.0 1969-12-31 16:00:02.351 NULL k17Am8uPHWk02cEf1jet k17Am8uPHWk02cEf1jet qrXLLNX1 true
+1 2 3 4 3.14 6.28 5.99 NULL 2014-09-01 its a beautiful day in the neighbhorhood a beautiful day for a neighbor wont you be mine true

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedSep 23, '14 at 3:36p
activeSep 23, '14 at 3:36p
posts1
users1
websitehive.apache.org

1 user in discussion

Gates: 1 post

People

Translate

site design / logo © 2021 Grokbase