hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r831136 - in /hadoop/hive/trunk: ./ ql/src/java/org/apache/hadoop/hive/ql/parse/ ql/src/test/queries/clientnegative/ ql/src/test/results/clientnegative/
Date Thu, 29 Oct 2009 22:45:13 GMT
Author: namit
Date: Thu Oct 29 22:45:12 2009
New Revision: 831136

URL: http://svn.apache.org/viewvc?rev=831136&view=rev
Log:
HIVE-840. No error if user specifies multiple columns of same name as
output (He Yongqiang via namit)

Added:
    hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform.q
    hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform_schema.q
    hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform.q.out
    hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform_schema.q.out
Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=831136&r1=831135&r2=831136&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Thu Oct 29 22:45:12 2009
@@ -222,6 +222,9 @@
 
     HIVE-905. Smallint not working for typedbyteserde. (Namit Jain via zshao)
 
+    HIVE-840. No error if user specifies multiple columns of same name as
+    output (He Yongqiang via namit)
+
 Release 0.4.0 -  Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java?rev=831136&r1=831135&r2=831136&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (original)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java Thu Oct 29
22:45:12 2009
@@ -104,7 +104,8 @@
   CTAS_PARCOL_COEXISTENCE("CREATE-TABLE-AS-SELECT does not support partitioning in the target
table."),
   CTAS_MULTI_LOADFILE("CREATE-TABLE-AS-SELECT results in multiple file load."),
   CTAS_EXTTBL_COEXISTENCE("CREATE-TABLE-AS-SELECT cannot create external table."),
-  TABLE_ALREADY_EXISTS("Table already exists:", "42S02");
+  TABLE_ALREADY_EXISTS("Table already exists:", "42S02"),
+  COLUMN_ALIAS_ALREADY_EXISTS("Column alias already exists:", "42S02");
   
   private String mesg;
   private String SQLState;

Modified: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=831136&r1=831135&r2=831136&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Thu
Oct 29 22:45:12 2009
@@ -1089,6 +1089,12 @@
     return null;
   }
 
+  private void failIfColAliasExists(Set<String> nameSet, String name) throws SemanticException
{
+    if(nameSet.contains(name))
+      throw new SemanticException(ErrorMsg.COLUMN_ALIAS_ALREADY_EXISTS.getMsg(name));
+    nameSet.add(name);
+  }
+
   @SuppressWarnings("nls")
   private Operator genScriptPlan(ASTNode trfm, QB qb,
       Operator input) throws SemanticException {
@@ -1120,16 +1126,21 @@
       ASTNode collist = (ASTNode) trfm.getChild(outputColsNum);
       int ccount = collist.getChildCount();
 
+      Set<String> colAliasNamesDuplicateCheck = new HashSet<String>();
       if (outputColNames) {
         for (int i=0; i < ccount; ++i) {
-          outputCols.add(new ColumnInfo(unescapeIdentifier(((ASTNode)collist.getChild(i)).getText()),
TypeInfoFactory.stringTypeInfo, null, false));
+          String colAlias = unescapeIdentifier(((ASTNode)collist.getChild(i)).getText());
+          failIfColAliasExists(colAliasNamesDuplicateCheck, colAlias);
+          outputCols.add(new ColumnInfo(colAlias, TypeInfoFactory.stringTypeInfo, null, false));
         }
       }
       else {
         for (int i=0; i < ccount; ++i) {
           ASTNode child = (ASTNode) collist.getChild(i);
           assert child.getType() == HiveParser.TOK_TABCOL;
-          outputCols.add(new ColumnInfo(unescapeIdentifier(((ASTNode)child.getChild(0)).getText()),
+          String colAlias = unescapeIdentifier(((ASTNode)child.getChild(0)).getText());
+          failIfColAliasExists(colAliasNamesDuplicateCheck, colAlias);
+          outputCols.add(new ColumnInfo(colAlias,
                                         TypeInfoUtils.getTypeInfoFromTypeString(DDLSemanticAnalyzer.getTypeName(((ASTNode)child.getChild(1)).getType())),
null, false));
         }
       }

Added: hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform.q?rev=831136&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform.q Thu
Oct 29 22:45:12 2009
@@ -0,0 +1 @@
+FROM src SELECT TRANSFORM (key, value) USING "awk -F'\001' '{print $0}'" AS (foo, foo);
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform_schema.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform_schema.q?rev=831136&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform_schema.q
(added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientnegative/duplicate_alias_in_transform_schema.q
Thu Oct 29 22:45:12 2009
@@ -0,0 +1 @@
+FROM src SELECT TRANSFORM (key, value) USING "awk -F'\001' '{print $0}'" AS (foo STRING,
foo STRING);
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform.q.out?rev=831136&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform.q.out
(added)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform.q.out
Thu Oct 29 22:45:12 2009
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: Column alias already exists: foo

Added: hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform_schema.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform_schema.q.out?rev=831136&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform_schema.q.out
(added)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/duplicate_alias_in_transform_schema.q.out
Thu Oct 29 22:45:12 2009
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: Column alias already exists: foo



Mime
View raw message