hive git commit: HIVE-10776 - Schema on insert for bucketed tables throwing NullPointerException(Eugene Koifman, reviewed by Alan Gates)
Repository: hive Updated Branches: refs/heads/master 95929308b - 0d93438a3 HIVE-10776 - Schema on insert for bucketed tables throwing NullPointerException(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/0d93438a Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0d93438a Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0d93438a Branch: refs/heads/master Commit: 0d93438a3543cb64cbe2ebcdc21e5b40c1dd86e6 Parents: 9592930 Author: Eugene Koifman ekoif...@hortonworks.com Authored: Fri May 22 13:50:40 2015 -0700 Committer: Eugene Koifman ekoif...@hortonworks.com Committed: Fri May 22 13:50:40 2015 -0700 -- .../hadoop/hive/ql/parse/SemanticAnalyzer.java | 9 +- .../clientpositive/insert_into_with_schema2.q | 23 + .../insert_into_with_schema2.q.out | 98 3 files changed, 126 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hive/blob/0d93438a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java -- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 4346f60..7f355e5 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -3910,7 +3910,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { * @throws SemanticException */ private void handleInsertStatementSpec(ListExprNodeDesc col_list, String dest, - RowResolver out_rwsch, RowResolver inputRR, QB qb, + RowResolver outputRR, RowResolver inputRR, QB qb, ASTNode selExprList) throws SemanticException { //(z,x) ListString targetTableSchema = qb.getParseInfo().getDestSchemaForClause(dest);//specified in the query @@ -3932,7 +3932,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { MapString, ColumnInfo targetCol2ColumnInfo = new HashMapString, ColumnInfo(); int colListPos = 0; for(String targetCol : targetTableSchema) { - targetCol2ColumnInfo.put(targetCol, out_rwsch.getColumnInfos().get(colListPos)); + targetCol2ColumnInfo.put(targetCol, outputRR.getColumnInfos().get(colListPos)); targetCol2Projection.put(targetCol, col_list.get(colListPos++)); } Table target = qb.getMetaData().getDestTableForAlias(dest); @@ -3976,16 +3976,17 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { t.setText(TOK_NULL); ExprNodeDesc exp = genExprNodeDesc(new ASTNode(t), inputRR, tcCtx); new_col_list.add(exp); -final String tableAlias = ;//is this OK? this column doesn't come from any table +final String tableAlias = null;//this column doesn't come from any table ColumnInfo colInfo = new ColumnInfo(getColumnInternalName(colListPos), exp.getWritableObjectInspector(), tableAlias, false); newSchema.add(colInfo); +outputRR.addMappingOnly(colInfo.getTabAlias(), colInfo.getInternalName(), colInfo); } colListPos++; } col_list.clear(); col_list.addAll(new_col_list); -out_rwsch.setRowSchema(new RowSchema(newSchema)); +outputRR.setRowSchema(new RowSchema(newSchema)); } String recommendName(ExprNodeDesc exp, String colAlias) { if (!colAlias.startsWith(autogenColAliasPrfxLbl)) { http://git-wip-us.apache.org/repos/asf/hive/blob/0d93438a/ql/src/test/queries/clientpositive/insert_into_with_schema2.q -- diff --git a/ql/src/test/queries/clientpositive/insert_into_with_schema2.q b/ql/src/test/queries/clientpositive/insert_into_with_schema2.q new file mode 100644 index 000..b7c6b58 --- /dev/null +++ b/ql/src/test/queries/clientpositive/insert_into_with_schema2.q @@ -0,0 +1,23 @@ +-- SORT_QUERY_RESULTS; + +set hive.enforce.bucketing=true; + +create table studenttab10k (age2 int); +insert into studenttab10k values(1); + +create table student_acid (age int, grade int) + clustered by (age) into 1 buckets; + +insert into student_acid(age) select * from studenttab10k; + +select * from student_acid; + +insert into student_acid(grade, age) select 3 g, * from studenttab10k; + +select * from student_acid; + +insert into student_acid(grade, age) values(20, 2); + +insert into student_acid(age) values(22); + +select * from student_acid; http://git-wip-us.apache.org/repos/asf/hive/blob/0d93438a/ql/src/test/results/clientpositive/insert_into_with_schema2.q.out
hive git commit: HIVE-10776 - Schema on insert for bucketed tables throwing NullPointerException
Repository: hive Updated Branches: refs/heads/branch-1.2 7b89fad81 - 613b559f2 HIVE-10776 - Schema on insert for bucketed tables throwing NullPointerException Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/613b559f Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/613b559f Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/613b559f Branch: refs/heads/branch-1.2 Commit: 613b559f2e1b027c64f265120c202f6af4138930 Parents: 7b89fad Author: Eugene Koifman ekoif...@hortonworks.com Authored: Fri May 22 15:14:54 2015 -0700 Committer: Eugene Koifman ekoif...@hortonworks.com Committed: Fri May 22 15:14:54 2015 -0700 -- .../hadoop/hive/ql/parse/SemanticAnalyzer.java | 9 +- .../clientpositive/insert_into_with_schema2.q | 23 + .../insert_into_with_schema2.q.out | 98 3 files changed, 126 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hive/blob/613b559f/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java -- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index bf889fc..50c57fc 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -3907,7 +3907,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { * @throws SemanticException */ private void handleInsertStatementSpec(ListExprNodeDesc col_list, String dest, - RowResolver out_rwsch, RowResolver inputRR, QB qb, + RowResolver outputRR, RowResolver inputRR, QB qb, ASTNode selExprList) throws SemanticException { //(z,x) ListString targetTableSchema = qb.getParseInfo().getDestSchemaForClause(dest);//specified in the query @@ -3929,7 +3929,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { MapString, ColumnInfo targetCol2ColumnInfo = new HashMapString, ColumnInfo(); int colListPos = 0; for(String targetCol : targetTableSchema) { - targetCol2ColumnInfo.put(targetCol, out_rwsch.getColumnInfos().get(colListPos)); + targetCol2ColumnInfo.put(targetCol, outputRR.getColumnInfos().get(colListPos)); targetCol2Projection.put(targetCol, col_list.get(colListPos++)); } Table target = qb.getMetaData().getDestTableForAlias(dest); @@ -3973,16 +3973,17 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { t.setText(TOK_NULL); ExprNodeDesc exp = genExprNodeDesc(new ASTNode(t), inputRR, tcCtx); new_col_list.add(exp); -final String tableAlias = ;//is this OK? this column doesn't come from any table +final String tableAlias = null;//this column doesn't come from any table ColumnInfo colInfo = new ColumnInfo(getColumnInternalName(colListPos), exp.getWritableObjectInspector(), tableAlias, false); newSchema.add(colInfo); +outputRR.addMappingOnly(colInfo.getTabAlias(), colInfo.getInternalName(), colInfo); } colListPos++; } col_list.clear(); col_list.addAll(new_col_list); -out_rwsch.setRowSchema(new RowSchema(newSchema)); +outputRR.setRowSchema(new RowSchema(newSchema)); } String recommendName(ExprNodeDesc exp, String colAlias) { if (!colAlias.startsWith(autogenColAliasPrfxLbl)) { http://git-wip-us.apache.org/repos/asf/hive/blob/613b559f/ql/src/test/queries/clientpositive/insert_into_with_schema2.q -- diff --git a/ql/src/test/queries/clientpositive/insert_into_with_schema2.q b/ql/src/test/queries/clientpositive/insert_into_with_schema2.q new file mode 100644 index 000..b7c6b58 --- /dev/null +++ b/ql/src/test/queries/clientpositive/insert_into_with_schema2.q @@ -0,0 +1,23 @@ +-- SORT_QUERY_RESULTS; + +set hive.enforce.bucketing=true; + +create table studenttab10k (age2 int); +insert into studenttab10k values(1); + +create table student_acid (age int, grade int) + clustered by (age) into 1 buckets; + +insert into student_acid(age) select * from studenttab10k; + +select * from student_acid; + +insert into student_acid(grade, age) select 3 g, * from studenttab10k; + +select * from student_acid; + +insert into student_acid(grade, age) values(20, 2); + +insert into student_acid(age) values(22); + +select * from student_acid; http://git-wip-us.apache.org/repos/asf/hive/blob/613b559f/ql/src/test/results/clientpositive/insert_into_with_schema2.q.out --