hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1310126 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/parse/ test/queries/clientpositive/ test/queries/negative/ test/results/clientpositive/ test/results/compiler/errors/
Date Thu, 05 Apr 2012 23:07:14 GMT
Author: namit
Date: Thu Apr  5 23:07:14 2012
New Revision: 1310126

URL: http://svn.apache.org/viewvc?rev=1310126&view=rev
Log:
HIVE-2863 Ambiguous table name or column reference message displays when table and column
names are the same (Navis via namit)


Added:
    hive/trunk/ql/src/test/queries/clientpositive/nomore_ambiguous_table_col.q
    hive/trunk/ql/src/test/results/clientpositive/nomore_ambiguous_table_col.q.out
Removed:
    hive/trunk/ql/src/test/queries/negative/ambiguous_table_col.q
    hive/trunk/ql/src/test/results/compiler/errors/ambiguous_table_col.q.out
Modified:
    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/TypeCheckProcFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java?rev=1310126&r1=1310125&r2=1310126&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 Thu Apr
 5 23:07:14 2012
@@ -387,6 +387,7 @@ public final class TypeCheckProcFactory 
       }
 
       ASTNode expr = (ASTNode) nd;
+      ASTNode parent = stack.size() > 1 ? (ASTNode) stack.get(stack.size() - 2) : null;
       RowResolver input = ctx.getInputRR();
 
       if (expr.getType() != HiveParser.TOK_TABLE_OR_COL) {
@@ -403,9 +404,14 @@ public final class TypeCheckProcFactory 
 
       if (isTableAlias) {
         if (colInfo != null) {
-          // it's a table alias, and also a column
-          ctx.setError(ErrorMsg.AMBIGUOUS_TABLE_OR_COLUMN.getMsg(expr), expr);
-          return null;
+          if (parent != null && parent.getType() == HiveParser.DOT) {
+            // It's a table alias.
+            return null;
+          }
+          // It's a column.
+          return new ExprNodeColumnDesc(colInfo.getType(), colInfo
+              .getInternalName(), colInfo.getTabAlias(), colInfo
+              .getIsVirtualCol());
         } else {
           // It's a table alias.
           // We will process that later in DOT.

Added: hive/trunk/ql/src/test/queries/clientpositive/nomore_ambiguous_table_col.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/nomore_ambiguous_table_col.q?rev=1310126&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/nomore_ambiguous_table_col.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/nomore_ambiguous_table_col.q Thu Apr  5
23:07:14 2012
@@ -0,0 +1,9 @@
+-- was negative/ambiguous_table_col.q
+
+drop table ambiguous;
+create table ambiguous (key string, value string);
+
+FROM src key
+INSERT OVERWRITE TABLE ambiguous SELECT key.key, key.value WHERE key.value < 'val_100';
+
+drop table ambiguous;

Added: hive/trunk/ql/src/test/results/clientpositive/nomore_ambiguous_table_col.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/nomore_ambiguous_table_col.q.out?rev=1310126&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/nomore_ambiguous_table_col.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/nomore_ambiguous_table_col.q.out Thu Apr
 5 23:07:14 2012
@@ -0,0 +1,35 @@
+PREHOOK: query: -- was negative/ambiguous_table_col.q
+
+drop table ambiguous
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: -- was negative/ambiguous_table_col.q
+
+drop table ambiguous
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: create table ambiguous (key string, value string)
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: create table ambiguous (key string, value string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@ambiguous
+PREHOOK: query: FROM src key
+INSERT OVERWRITE TABLE ambiguous SELECT key.key, key.value WHERE key.value < 'val_100'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: default@ambiguous
+POSTHOOK: query: FROM src key
+INSERT OVERWRITE TABLE ambiguous SELECT key.key, key.value WHERE key.value < 'val_100'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: default@ambiguous
+POSTHOOK: Lineage: ambiguous.key SIMPLE [(src)key.FieldSchema(name:key, type:string, comment:default),
]
+POSTHOOK: Lineage: ambiguous.value SIMPLE [(src)key.FieldSchema(name:value, type:string,
comment:default), ]
+PREHOOK: query: drop table ambiguous
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@ambiguous
+PREHOOK: Output: default@ambiguous
+POSTHOOK: query: drop table ambiguous
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@ambiguous
+POSTHOOK: Output: default@ambiguous
+POSTHOOK: Lineage: ambiguous.key SIMPLE [(src)key.FieldSchema(name:key, type:string, comment:default),
]
+POSTHOOK: Lineage: ambiguous.value SIMPLE [(src)key.FieldSchema(name:value, type:string,
comment:default), ]



Mime
View raw message