You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ga...@apache.org on 2014/09/20 16:33:56 UTC
svn commit: r1626448 - in /hive/trunk/ql/src:
java/org/apache/hadoop/hive/ql/parse/ test/org/apache/hadoop/hive/ql/parse/
test/queries/clientpositive/ test/results/clientpositive/
test/results/clientpositive/tez/
Author: gates
Date: Sat Sep 20 14:33:55 2014
New Revision: 1626448
URL: http://svn.apache.org/r1626448
Log:
HIVE-8105 booleans and nulls not handled properly in insert/values (Alan Gates, reviewed by Eugene Koifman)
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java
hive/trunk/ql/src/test/queries/clientpositive/insert_values_non_partitioned.q
hive/trunk/ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1626448&r1=1626447&r2=1626448&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Sat Sep 20 14:33:55 2014
@@ -804,7 +804,8 @@ public class SemanticAnalyzer extends Ba
return PlanUtils.stripQuotes(expr.getText());
case HiveParser.KW_FALSE:
- return "FALSE";
+ // UDFToBoolean casts any non-empty string to true, so set this to false
+ return "";
case HiveParser.KW_TRUE:
return "TRUE";
@@ -812,6 +813,10 @@ public class SemanticAnalyzer extends Ba
case HiveParser.MINUS:
return "-" + unparseExprForValuesClause((ASTNode)expr.getChildren().get(0));
+ case HiveParser.TOK_NULL:
+ // Hive's text input will translate this as a null
+ return "\\N";
+
default:
throw new SemanticException("Expression of type " + expr.getText() +
" not supported in insert/values");
Modified: hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java?rev=1626448&r1=1626447&r2=1626448&view=diff
==============================================================================
--- hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java Sat Sep 20 14:33:55 2014
@@ -198,7 +198,7 @@ public class TestUpdateDeleteSemanticAna
@Test
public void testInsertValues() throws Exception {
try {
- ReturnInfo rc = parseAndAnalyze("insert into table T values ('abc', 3), ('ghi', 5)",
+ ReturnInfo rc = parseAndAnalyze("insert into table T values ('abc', 3), ('ghi', null)",
"testInsertValues");
LOG.info(explain((SemanticAnalyzer)rc.sem, rc.plan, rc.ast.dump()));
Modified: hive/trunk/ql/src/test/queries/clientpositive/insert_values_non_partitioned.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/insert_values_non_partitioned.q?rev=1626448&r1=1626447&r2=1626448&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/insert_values_non_partitioned.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/insert_values_non_partitioned.q Sat Sep 20 14:33:55 2014
@@ -12,12 +12,14 @@ create table acid_ivnp(ti tinyint,
de decimal(5,2),
t timestamp,
dt date,
+ b boolean,
s string,
vc varchar(128),
ch char(12)) clustered by (i) into 2 buckets stored as orc;
insert into table acid_ivnp values
- (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', 'mary had a little lamb', 'ring around the rosie', 'red'),
- (3, 25, 6553, 429496729, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', 'its fleece was white as snow', 'a pocket full of posies', 'blue' );
+ (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', true, 'mary had a little lamb', 'ring around the rosie', 'red'),
+ (null, null, null, null, null, null, null, null, null, null, null, null, null),
+ (3, 25, 6553, null, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', false, 'its fleece was white as snow', 'a pocket full of posies', 'blue' );
-select ti, si, i, bi, f, d, de, t, dt, s, vc, ch from acid_ivnp order by ti;
+select * from acid_ivnp order by ti;
Modified: hive/trunk/ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out?rev=1626448&r1=1626447&r2=1626448&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out Sat Sep 20 14:33:55 2014
@@ -7,6 +7,7 @@ PREHOOK: query: create table acid_ivnp(t
de decimal(5,2),
t timestamp,
dt date,
+ b boolean,
s string,
vc varchar(128),
ch char(12)) clustered by (i) into 2 buckets stored as orc
@@ -22,6 +23,7 @@ POSTHOOK: query: create table acid_ivnp(
de decimal(5,2),
t timestamp,
dt date,
+ b boolean,
s string,
vc varchar(128),
ch char(12)) clustered by (i) into 2 buckets stored as orc
@@ -29,36 +31,40 @@ POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@acid_ivnp
PREHOOK: query: insert into table acid_ivnp values
- (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', 'mary had a little lamb', 'ring around the rosie', 'red'),
- (3, 25, 6553, 429496729, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
+ (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', true, 'mary had a little lamb', 'ring around the rosie', 'red'),
+ (null, null, null, null, null, null, null, null, null, null, null, null, null),
+ (3, 25, 6553, null, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', false, 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
PREHOOK: type: QUERY
PREHOOK: Input: default@values__tmp__table__1
PREHOOK: Output: default@acid_ivnp
POSTHOOK: query: insert into table acid_ivnp values
- (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', 'mary had a little lamb', 'ring around the rosie', 'red'),
- (3, 25, 6553, 429496729, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
+ (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', true, 'mary had a little lamb', 'ring around the rosie', 'red'),
+ (null, null, null, null, null, null, null, null, null, null, null, null, null),
+ (3, 25, 6553, null, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', false, 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
POSTHOOK: type: QUERY
POSTHOOK: Input: default@values__tmp__table__1
POSTHOOK: Output: default@acid_ivnp
+POSTHOOK: Lineage: acid_ivnp.b EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col10, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.bi EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col4, type:string, comment:), ]
-POSTHOOK: Lineage: acid_ivnp.ch EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col12, type:string, comment:), ]
+POSTHOOK: Lineage: acid_ivnp.ch EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col13, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.d EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col6, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.de EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col7, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.dt EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col9, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.f EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col5, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.i EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, type:string, comment:), ]
-POSTHOOK: Lineage: acid_ivnp.s SIMPLE [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col10, type:string, comment:), ]
+POSTHOOK: Lineage: acid_ivnp.s SIMPLE [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col11, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.si EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.t EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col8, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.ti EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
-POSTHOOK: Lineage: acid_ivnp.vc EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col11, type:string, comment:), ]
-PREHOOK: query: select ti, si, i, bi, f, d, de, t, dt, s, vc, ch from acid_ivnp order by ti
+POSTHOOK: Lineage: acid_ivnp.vc EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col12, type:string, comment:), ]
+PREHOOK: query: select * from acid_ivnp order by ti
PREHOOK: type: QUERY
PREHOOK: Input: default@acid_ivnp
#### A masked pattern was here ####
-POSTHOOK: query: select ti, si, i, bi, f, d, de, t, dt, s, vc, ch from acid_ivnp order by ti
+POSTHOOK: query: select * from acid_ivnp order by ti
POSTHOOK: type: QUERY
POSTHOOK: Input: default@acid_ivnp
#### A masked pattern was here ####
-1 257 65537 4294967297 3.14 3.141592654 109.23 2014-08-25 17:21:30 2014-08-25 mary had a little lamb ring around the rosie red
-3 25 6553 429496729 0.14 1923.141592654 1.23 2014-08-24 17:21:30 2014-08-26 its fleece was white as snow a pocket full of posies blue
+NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
+1 257 65537 4294967297 3.14 3.141592654 109.23 2014-08-25 17:21:30 2014-08-25 true mary had a little lamb ring around the rosie red
+3 25 6553 NULL 0.14 1923.141592654 1.23 2014-08-24 17:21:30 2014-08-26 false its fleece was white as snow a pocket full of posies blue
Modified: hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out?rev=1626448&r1=1626447&r2=1626448&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out Sat Sep 20 14:33:55 2014
@@ -7,6 +7,7 @@ PREHOOK: query: create table acid_ivnp(t
de decimal(5,2),
t timestamp,
dt date,
+ b boolean,
s string,
vc varchar(128),
ch char(12)) clustered by (i) into 2 buckets stored as orc
@@ -22,6 +23,7 @@ POSTHOOK: query: create table acid_ivnp(
de decimal(5,2),
t timestamp,
dt date,
+ b boolean,
s string,
vc varchar(128),
ch char(12)) clustered by (i) into 2 buckets stored as orc
@@ -29,36 +31,40 @@ POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@acid_ivnp
PREHOOK: query: insert into table acid_ivnp values
- (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', 'mary had a little lamb', 'ring around the rosie', 'red'),
- (3, 25, 6553, 429496729, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
+ (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', true, 'mary had a little lamb', 'ring around the rosie', 'red'),
+ (null, null, null, null, null, null, null, null, null, null, null, null, null),
+ (3, 25, 6553, null, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', false, 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
PREHOOK: type: QUERY
PREHOOK: Input: default@values__tmp__table__1
PREHOOK: Output: default@acid_ivnp
POSTHOOK: query: insert into table acid_ivnp values
- (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', 'mary had a little lamb', 'ring around the rosie', 'red'),
- (3, 25, 6553, 429496729, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
+ (1, 257, 65537, 4294967297, 3.14, 3.141592654, 109.23, '2014-08-25 17:21:30.0', '2014-08-25', true, 'mary had a little lamb', 'ring around the rosie', 'red'),
+ (null, null, null, null, null, null, null, null, null, null, null, null, null),
+ (3, 25, 6553, null, 0.14, 1923.141592654, 1.2301, '2014-08-24 17:21:30.0', '2014-08-26', false, 'its fleece was white as snow', 'a pocket full of posies', 'blue' )
POSTHOOK: type: QUERY
POSTHOOK: Input: default@values__tmp__table__1
POSTHOOK: Output: default@acid_ivnp
+POSTHOOK: Lineage: acid_ivnp.b EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col10, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.bi EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col4, type:string, comment:), ]
-POSTHOOK: Lineage: acid_ivnp.ch EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col12, type:string, comment:), ]
+POSTHOOK: Lineage: acid_ivnp.ch EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col13, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.d EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col6, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.de EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col7, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.dt EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col9, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.f EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col5, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.i EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, type:string, comment:), ]
-POSTHOOK: Lineage: acid_ivnp.s SIMPLE [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col10, type:string, comment:), ]
+POSTHOOK: Lineage: acid_ivnp.s SIMPLE [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col11, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.si EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.t EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col8, type:string, comment:), ]
POSTHOOK: Lineage: acid_ivnp.ti EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
-POSTHOOK: Lineage: acid_ivnp.vc EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col11, type:string, comment:), ]
-PREHOOK: query: select ti, si, i, bi, f, d, de, t, dt, s, vc, ch from acid_ivnp order by ti
+POSTHOOK: Lineage: acid_ivnp.vc EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col12, type:string, comment:), ]
+PREHOOK: query: select * from acid_ivnp order by ti
PREHOOK: type: QUERY
PREHOOK: Input: default@acid_ivnp
#### A masked pattern was here ####
-POSTHOOK: query: select ti, si, i, bi, f, d, de, t, dt, s, vc, ch from acid_ivnp order by ti
+POSTHOOK: query: select * from acid_ivnp order by ti
POSTHOOK: type: QUERY
POSTHOOK: Input: default@acid_ivnp
#### A masked pattern was here ####
-1 257 65537 4294967297 3.14 3.141592654 109.23 2014-08-25 17:21:30 2014-08-25 mary had a little lamb ring around the rosie red
-3 25 6553 429496729 0.14 1923.141592654 1.23 2014-08-24 17:21:30 2014-08-26 its fleece was white as snow a pocket full of posies blue
+NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
+1 257 65537 4294967297 3.14 3.141592654 109.23 2014-08-25 17:21:30 2014-08-25 true mary had a little lamb ring around the rosie red
+3 25 6553 NULL 0.14 1923.141592654 1.23 2014-08-24 17:21:30 2014-08-26 false its fleece was white as snow a pocket full of posies blue