You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by na...@apache.org on 2012/09/15 17:14:17 UTC
svn commit: r1385078 - in /hive/trunk/ql/src:
java/org/apache/hadoop/hive/ql/parse/ test/queries/clientnegative/
test/results/clientnegative/
Author: namit
Date: Sat Sep 15 15:14:16 2012
New Revision: 1385078
URL: http://svn.apache.org/viewvc?rev=1385078&view=rev
Log:
HIVE-3452 Missing column causes null pointer exception
(Jean Xu via namit)
Added:
hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column.q
hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_subquery.q
hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_tablename.q
hive/trunk/ql/src/test/results/clientnegative/invalid_select_column.q.out
hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_subquery.q.out
hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_tablename.q.out
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
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=1385078&r1=1385077&r2=1385078&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 15 15:14:16 2012
@@ -7699,7 +7699,11 @@ public class SemanticAnalyzer extends Ba
TypeCheckProcFactory.genExprNode(expr, tcCtx);
ExprNodeDesc desc = (ExprNodeDesc) nodeOutputs.get(expr);
if (desc == null) {
- throw new SemanticException(tcCtx.getError());
+ String errMsg = tcCtx.getError();
+ if ( errMsg == null) {
+ errMsg = "Error in parsing ";
+ }
+ throw new SemanticException(errMsg);
}
if (!unparseTranslator.isEnabled()) {
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java?rev=1385078&r1=1385077&r2=1385078&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java Sat Sep 15 15:14:16 2012
@@ -890,6 +890,12 @@ public final class TypeCheckProcFactory
// If any of the children contains null, then return a null
// this is a hack for now to handle the group by case
if (children.contains(null)) {
+ RowResolver input = ctx.getInputRR();
+ List<String> possibleColumnNames = input.getReferenceableColumnAliases(null, -1);
+ String reason = String.format("(possible column names are: %s)",
+ StringUtils.join(possibleColumnNames, ", "));
+ ctx.setError(ErrorMsg.INVALID_COLUMN.getMsg(expr.getChild(0), reason),
+ expr);
return null;
}
Added: hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column.q?rev=1385078&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column.q Sat Sep 15 15:14:16 2012
@@ -0,0 +1,4 @@
+-- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile ;
+
+select * from test_invalid_column where column1=123;
Added: hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_subquery.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_subquery.q?rev=1385078&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_subquery.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_subquery.q Sat Sep 15 15:14:16 2012
@@ -0,0 +1,4 @@
+-- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile ;
+
+select * from (select * from test_invalid_column) subq where subq = 123;
Added: hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_tablename.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_tablename.q?rev=1385078&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_tablename.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/invalid_select_column_with_tablename.q Sat Sep 15 15:14:16 2012
@@ -0,0 +1,4 @@
+-- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile ;
+
+select * from test_invalid_column where test_invalid_column=123;
Added: hive/trunk/ql/src/test/results/clientnegative/invalid_select_column.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_select_column.q.out?rev=1385078&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/invalid_select_column.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/invalid_select_column.q.out Sat Sep 15 15:14:16 2012
@@ -0,0 +1,8 @@
+PREHOOK: query: -- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: -- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@test_invalid_column
+FAILED: SemanticException [Error 10004]: Line 3:41 Invalid table alias or column reference 'column1': (possible column names are: key, value, year, month)
Added: hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_subquery.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_subquery.q.out?rev=1385078&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_subquery.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_subquery.q.out Sat Sep 15 15:14:16 2012
@@ -0,0 +1,8 @@
+PREHOOK: query: -- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: -- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@test_invalid_column
+FAILED: SemanticException [Error 10002]: Line 3:61 Invalid column reference 'subq': (possible column names are: key, value, year, month)
Added: hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_tablename.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_tablename.q.out?rev=1385078&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_tablename.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/invalid_select_column_with_tablename.q.out Sat Sep 15 15:14:16 2012
@@ -0,0 +1,8 @@
+PREHOOK: query: -- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: -- Create table
+create table if not exists test_invalid_column(key string, value string ) partitioned by (year string, month string) stored as textfile
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@test_invalid_column
+FAILED: SemanticException [Error 10002]: Line 3:41 Invalid column reference 'test_invalid_column': (possible column names are: key, value, year, month)