hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r792600 - 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, 09 Jul 2009 16:45:22 GMT
Author: namit
Date: Thu Jul  9 16:45:22 2009
New Revision: 792600

URL: http://svn.apache.org/viewvc?rev=792600&view=rev
Log:
HIVE-527. Inserting into a partitioned table without specifying the partition field should
fail.
(He Yongqiang via namit)


Added:
    hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_insert.q
    hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_load.q
    hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_insert.q.out
    hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_load.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/LoadSemanticAnalyzer.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=792600&r1=792599&r2=792600&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Thu Jul  9 16:45:22 2009
@@ -319,6 +319,9 @@
     HIVE-616. Make hive work with symbolic linked sub directories
     (Zheng Shao via rmurthy)
 
+    HIVE-527. Inserting into a partitioned table without specifying the partition field should
fail.
+    (He Yongqiang via namit)
+
 Release 0.3.1 - 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=792600&r1=792599&r2=792600&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 Jul  9
16:45:22 2009
@@ -83,7 +83,8 @@
   NO_OUTER_MAPJOIN("Map Join cannot be performed with Outer join"),
   INVALID_MAPJOIN_HINT("neither table specified as map-table"),
   INVALID_MAPJOIN_TABLE("result of a union cannot be a map table"),
-  NON_BUCKETED_TABLE("Sampling Expression Needed for Non-Bucketed Table");
+  NON_BUCKETED_TABLE("Sampling Expression Needed for Non-Bucketed Table"),
+  NEED_PARTITION_ERROR("need to specify partition columns because the destination table is
partitioned.");
 
   private String mesg;
   ErrorMsg(String mesg) {

Modified: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/LoadSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/LoadSemanticAnalyzer.java?rev=792600&r1=792599&r2=792600&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/LoadSemanticAnalyzer.java
(original)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/LoadSemanticAnalyzer.java
Thu Jul  9 16:45:22 2009
@@ -23,6 +23,7 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.HashMap;
+import java.util.List;
 
 import org.antlr.runtime.tree.Tree;
 import org.apache.commons.lang.StringUtils;
@@ -30,6 +31,7 @@
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.ql.exec.Task;
 import org.apache.hadoop.hive.ql.exec.TaskFactory;
 import org.apache.hadoop.hive.ql.exec.Utilities;
@@ -176,6 +178,12 @@
     tableSpec ts = new tableSpec(db, conf, (ASTNode) table_t);
     URI toURI = (ts.partHandle != null) ? ts.partHandle.getDataLocation() : ts.tableHandle.getDataLocation();
 
+    List<FieldSchema> parts = ts.tableHandle.getTTable().getPartitionKeys();
+    if (isOverWrite && (parts != null && parts.size() > 0)
+        && (ts.partSpec == null || ts.partSpec.size() == 0)) {
+      throw new SemanticException(ErrorMsg.NEED_PARTITION_ERROR.getMsg());
+    }
+    
     // make sure the arguments make sense
     applyConstraints(fromURI, toURI, from_t, isLocal);
 

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=792600&r1=792599&r2=792600&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
Jul  9 16:45:22 2009
@@ -2276,6 +2276,11 @@
     case QBMetaData.DEST_TABLE: {
 
         dest_tab = qbm.getDestTableForAlias(dest);
+        //check for partition
+        List<FieldSchema> parts = dest_tab.getTTable().getPartitionKeys();
+        if(parts != null && parts.size() > 0) {
+          throw new SemanticException(ErrorMsg.NEED_PARTITION_ERROR.getMsg());
+        }
         dest_path = dest_tab.getPath();
         queryTmpdir = ctx.getExternalTmpFileURI(dest_path.toUri());
         table_desc = Utilities.getTableDesc(dest_tab);

Added: hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_insert.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_insert.q?rev=792600&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_insert.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_insert.q Thu Jul  9 16:45:22
2009
@@ -0,0 +1,8 @@
+DROP TABLE nopart_insert;
+CREATE TABLE nopart_insert(a STRING, b STRING) PARTITIONED BY (ds STRING);
+
+INSERT OVERWRITE TABLE nopart_insert 
+SELECT TRANSFORM(src.key, src.value) USING '../data/scripts/error_script' AS (tkey, tvalue)
+FROM src;
+
+DROP TABLE nopart_insert;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_load.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_load.q?rev=792600&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_load.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientnegative/nopart_load.q Thu Jul  9 16:45:22
2009
@@ -0,0 +1,6 @@
+DROP TABLE nopart_load;
+CREATE TABLE nopart_load(a STRING, b STRING) PARTITIONED BY (ds STRING);
+
+load data local inpath '../data/files/kv1.txt' overwrite into table nopart_load ;
+
+DROP TABLE nopart_load;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_insert.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_insert.q.out?rev=792600&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_insert.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_insert.q.out Thu Jul  9 16:45:22
2009
@@ -0,0 +1,3 @@
+query: DROP TABLE nopart_insert
+query: CREATE TABLE nopart_insert(a STRING, b STRING) PARTITIONED BY (ds STRING)
+FAILED: Error in semantic analysis: need to specify partition columns because the destination
table is partitioned.

Added: hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_load.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_load.q.out?rev=792600&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_load.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/nopart_load.q.out Thu Jul  9 16:45:22
2009
@@ -0,0 +1,3 @@
+query: DROP TABLE nopart_load
+query: CREATE TABLE nopart_load(a STRING, b STRING) PARTITIONED BY (ds STRING)
+FAILED: Error in semantic analysis: need to specify partition columns because the destination
table is partitioned.



Mime
View raw message