diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 392f7ce..1e1e736 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -805,7 +805,7 @@ private String unparseExprForValuesClause(ASTNode expr) throws SemanticException return PlanUtils.stripQuotes(expr.getText()); case HiveParser.KW_FALSE: - return "FALSE"; + return ""; case HiveParser.KW_TRUE: return "TRUE"; @@ -813,6 +813,9 @@ private String unparseExprForValuesClause(ASTNode expr) throws SemanticException case HiveParser.MINUS: return "-" + unparseExprForValuesClause((ASTNode)expr.getChildren().get(0)); + case HiveParser.TOK_NULL: + return ""; + default: throw new SemanticException("Expression of type " + expr.getText() + " not supported in insert/values"); diff --git ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java index 4d1b7df..301b531 100644 --- ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java +++ ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java @@ -198,7 +198,7 @@ public void testUpdateOnePartitionWhere() throws Exception { @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())); diff --git ql/src/test/queries/clientpositive/insert_values_non_partitioned.q ql/src/test/queries/clientpositive/insert_values_non_partitioned.q index 6edfd6a..8e5b380 100644 --- ql/src/test/queries/clientpositive/insert_values_non_partitioned.q +++ ql/src/test/queries/clientpositive/insert_values_non_partitioned.q @@ -12,12 +12,13 @@ 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'), + (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; diff --git ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out index a6f8ac4..6564b87 100644 --- ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out +++ ql/src/test/results/clientpositive/insert_values_non_partitioned.q.out @@ -7,6 +7,7 @@ PREHOOK: query: 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 @@ -22,6 +23,7 @@ POSTHOOK: query: 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 @@ -29,36 +31,37 @@ 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'), + (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'), + (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 +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 diff --git ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out index a6f8ac4..6564b87 100644 --- ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out +++ ql/src/test/results/clientpositive/tez/insert_values_non_partitioned.q.out @@ -7,6 +7,7 @@ PREHOOK: query: 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 @@ -22,6 +23,7 @@ POSTHOOK: query: 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 @@ -29,36 +31,37 @@ 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'), + (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'), + (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 +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