hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1425755 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/ java/org/apache/hadoop/hive/ql/exec/ java/org/apache/hadoop/hive/ql/parse/ java/org/apache/hadoop/hive/ql/plan/ test/queries/clientnegative/ test/queries/clientpositive/ test...
Date Tue, 25 Dec 2012 16:57:38 GMT
Author: namit
Date: Tue Dec 25 16:57:38 2012
New Revision: 1425755

URL: http://svn.apache.org/viewvc?rev=1425755&view=rev
Log:
HIVE-3834 Support ALTER VIEW AS SELECT in Hive
(Zhenxiao Luo via namit)


Added:
    hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_not_exist.q
    hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_with_partition.q
    hive/trunk/ql/src/test/queries/clientpositive/alter_view_as_select.q
    hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_not_exist.q.out
    hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_with_partition.q.out
    hive/trunk/ql/src/test/results/clientpositive/alter_view_as_select.q.out
Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateViewDesc.java
    hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view1.q.out
    hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view2.q.out
    hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view3.q.out
    hive/trunk/ql/src/test/results/clientpositive/create_view.q.out

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java Tue Dec 25 16:57:38 2012
@@ -295,6 +295,13 @@ public enum ErrorMsg {
     "Please use the following syntax if not sure " +
     "whether the property existed or not:\n" +
     "ALTER TABLE tableName UNSET TBLPROPERTIES IF EXISTS (key1, key2, ...)\n"),
+  ALTER_VIEW_AS_SELECT_NOT_EXIST(10216,
+    "Cannot ALTER VIEW AS SELECT if view currently does not exist\n"),
+  REPLACE_VIEW_WITH_PARTITION(10217,
+    "Cannot replace a view with CREATE VIEW or REPLACE VIEW or " +
+    "ALTER VIEW AS SELECT if the view has paritions\n"),
+  EXISTING_TABLE_IS_NOT_VIEW(10218,
+    "Existing table is not a view\n"),
 
   SCRIPT_INIT_ERROR(20000, "Unable to initialize custom script."),
   SCRIPT_IO_ERROR(20001, "An error occurred while reading or writing to your custom script.
"

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Tue Dec 25 16:57:38
2012
@@ -3837,21 +3837,6 @@ public class DDLTask extends Task<DDLWor
     Table oldview = db.getTable(crtView.getViewName(), false);
     if (crtView.getOrReplace() && oldview != null) {
       // replace existing view
-      if (!oldview.getTableType().equals(TableType.VIRTUAL_VIEW)) {
-        throw new HiveException("Existing table is not a view");
-      }
-
-      if (crtView.getPartCols() == null
-          || crtView.getPartCols().isEmpty()
-          || !crtView.getPartCols().equals(oldview.getPartCols())) {
-        // if we are changing partition columns, check that partitions don't exist
-        if (!oldview.getPartCols().isEmpty() &&
-            !db.getPartitions(oldview).isEmpty()) {
-          throw new HiveException(
-              "Cannot add or drop partition columns with CREATE OR REPLACE VIEW if partitions
currently exist");
-        }
-      }
-
       // remove the existing partition columns from the field schema
       oldview.setViewOriginalText(crtView.getViewOriginalText());
       oldview.setViewExpandedText(crtView.getViewExpandedText());

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g Tue Dec 25 16:57:38 2012
@@ -199,6 +199,7 @@ TOK_CREATEFUNCTION;
 TOK_DROPFUNCTION;
 TOK_CREATEVIEW;
 TOK_DROPVIEW;
+TOK_ALTERVIEW_AS;
 TOK_ALTERVIEW_PROPERTIES;
 TOK_DROPVIEW_PROPERTIES;
 TOK_ALTERVIEW_ADDPARTS;
@@ -629,6 +630,8 @@ alterViewStatementSuffix
         -> ^(TOK_ALTERVIEW_ADDPARTS alterStatementSuffixAddPartitions)
     | alterStatementSuffixDropPartitions
         -> ^(TOK_ALTERVIEW_DROPPARTS alterStatementSuffixDropPartitions)
+    | name=tableName KW_AS selectStatement
+        -> ^(TOK_ALTERVIEW_AS $name selectStatement)
     ;
 
 alterIndexStatementSuffix

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=1425755&r1=1425754&r2=1425755&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 Tue Dec 25
16:57:38 2012
@@ -8211,7 +8211,8 @@ public class SemanticAnalyzer extends Ba
     }
 
     // analyze create view command
-    if (ast.getToken().getType() == HiveParser.TOK_CREATEVIEW) {
+    if (ast.getToken().getType() == HiveParser.TOK_CREATEVIEW ||
+        ast.getToken().getType() == HiveParser.TOK_ALTERVIEW_AS) {
       child = analyzeCreateView(ast, qb);
       SessionState.get().setCommandType(HiveOperation.CREATEVIEW);
       if (child == null) {
@@ -8244,6 +8245,11 @@ public class SemanticAnalyzer extends Ba
 
     if (createVwDesc != null) {
       saveViewDefinition();
+
+      // validate the create view statement
+      // at this point, the createVwDesc gets all the information for semantic check
+      validateCreateView(createVwDesc);
+
       // Since we're only creating a view (not executing it), we
       // don't need to optimize or translate the plan (and in fact, those
       // procedures can interfere with the view creation). So
@@ -8918,6 +8924,7 @@ public class SemanticAnalyzer extends Ba
     List<FieldSchema> cols = null;
     boolean ifNotExists = false;
     boolean orReplace = false;
+    boolean isAlterViewAs = false;
     String comment = null;
     ASTNode selectStmt = null;
     Map<String, String> tblProps = null;
@@ -8959,8 +8966,15 @@ public class SemanticAnalyzer extends Ba
       throw new SemanticException("Can't combine IF NOT EXISTS and OR REPLACE.");
     }
 
+    if (ast.getToken().getType() == HiveParser.TOK_ALTERVIEW_AS) {
+      isAlterViewAs = true;
+      orReplace = true;
+    }
+
     createVwDesc = new CreateViewDesc(
-      tableName, cols, comment, tblProps, partColNames, ifNotExists, orReplace);
+      tableName, cols, comment, tblProps, partColNames,
+      ifNotExists, orReplace, isAlterViewAs);
+
     unparseTranslator.enable();
     rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
         createVwDesc), conf));
@@ -8968,6 +8982,57 @@ public class SemanticAnalyzer extends Ba
     return selectStmt;
   }
 
+  // validate the create view statement
+  // the statement could be CREATE VIEW, REPLACE VIEW, or ALTER VIEW AS SELECT
+  // check semantic conditions
+  private void validateCreateView(CreateViewDesc createVwDesc)
+    throws SemanticException {
+    try {
+      Table oldView = db.getTable(createVwDesc.getViewName(), false);
+
+      // ALTER VIEW AS SELECT requires the view must exist
+      if (createVwDesc.getIsAlterViewAs() && oldView == null) {
+        String viewNotExistErrorMsg =
+          "The following view does not exist: " + createVwDesc.getViewName();
+        throw new SemanticException(
+          ErrorMsg.ALTER_VIEW_AS_SELECT_NOT_EXIST.getMsg(viewNotExistErrorMsg));
+      }
+
+      //replace view
+      if (createVwDesc.getOrReplace() && oldView != null) {
+
+        // Existing table is not a view
+        if (!oldView.getTableType().equals(TableType.VIRTUAL_VIEW)) {
+          String tableNotViewErrorMsg =
+            "The following is an existing table, not a view: " +
+            createVwDesc.getViewName();
+          throw new SemanticException(
+            ErrorMsg.EXISTING_TABLE_IS_NOT_VIEW.getMsg(tableNotViewErrorMsg));
+        }
+
+        // if old view has partitions, it could not be replaced
+        String partitionViewErrorMsg =
+          "The following view has partition, it could not be replaced: " +
+          createVwDesc.getViewName();
+        try {
+          if ((createVwDesc.getPartCols() == null ||
+            createVwDesc.getPartCols().isEmpty() ||
+            !createVwDesc.getPartCols().equals(oldView.getPartCols())) &&
+            !oldView.getPartCols().isEmpty() &&
+            !db.getPartitions(oldView).isEmpty()) {
+            throw new SemanticException(
+              ErrorMsg.REPLACE_VIEW_WITH_PARTITION.getMsg(partitionViewErrorMsg));
+          }
+        } catch (HiveException e) {
+          throw new SemanticException(
+            ErrorMsg.REPLACE_VIEW_WITH_PARTITION.getMsg(partitionViewErrorMsg));
+        }
+      }
+    } catch (HiveException e) {
+      throw new SemanticException(e.getMessage());
+    }
+  }
+
   private void decideExecMode(List<Task<? extends Serializable>> rootTasks, Context
ctx,
       GlobalLimitCtx globalLimitCtx)
     throws SemanticException {

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateViewDesc.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateViewDesc.java?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateViewDesc.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/CreateViewDesc.java Tue Dec 25 16:57:38
2012
@@ -43,6 +43,7 @@ public class CreateViewDesc extends DDLD
   private String comment;
   private boolean ifNotExists;
   private boolean orReplace;
+  private boolean isAlterViewAs;
 
   /**
    * For serialization only.
@@ -52,7 +53,8 @@ public class CreateViewDesc extends DDLD
 
   public CreateViewDesc(String viewName, List<FieldSchema> schema,
       String comment, Map<String, String> tblProps,
-      List<String> partColNames, boolean ifNotExists, boolean orReplace) {
+      List<String> partColNames, boolean ifNotExists,
+      boolean orReplace, boolean isAlterViewAs) {
     this.viewName = viewName;
     this.schema = schema;
     this.comment = comment;
@@ -60,6 +62,7 @@ public class CreateViewDesc extends DDLD
     this.partColNames = partColNames;
     this.ifNotExists = ifNotExists;
     this.orReplace = orReplace;
+    this.isAlterViewAs = isAlterViewAs;
   }
 
   @Explain(displayName = "name")
@@ -158,4 +161,13 @@ public class CreateViewDesc extends DDLD
   public void setOrReplace(boolean orReplace) {
     this.orReplace = orReplace;
   }
+
+  @Explain(displayName = "is alter view as select")
+  public boolean getIsAlterViewAs() {
+    return isAlterViewAs;
+  }
+
+  public void setIsAlterViewAs(boolean isAlterViewAs) {
+    this.isAlterViewAs = isAlterViewAs;
+  }
 }

Added: hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_not_exist.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_not_exist.q?rev=1425755&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_not_exist.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_not_exist.q Tue Dec
25 16:57:38 2012
@@ -0,0 +1,4 @@
+DROP VIEW testView;
+
+-- Cannot ALTER VIEW AS SELECT if view currently does not exist
+ALTER VIEW testView AS SELECT * FROM srcpart;

Added: hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_with_partition.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_with_partition.q?rev=1425755&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_with_partition.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/alter_view_as_select_with_partition.q Tue
Dec 25 16:57:38 2012
@@ -0,0 +1,12 @@
+CREATE VIEW testViewPart PARTITIONED ON (value)
+AS
+SELECT key, value
+FROM src
+WHERE key=86;
+
+ALTER VIEW testViewPart 
+ADD PARTITION (value='val_86') PARTITION (value='val_xyz'); 
+DESCRIBE FORMATTED testViewPart;
+
+-- If a view has partition, could not replace it with ALTER VIEW AS SELECT
+ALTER VIEW testViewPart as SELECT * FROM srcpart;

Added: hive/trunk/ql/src/test/queries/clientpositive/alter_view_as_select.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/alter_view_as_select.q?rev=1425755&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/alter_view_as_select.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/alter_view_as_select.q Tue Dec 25 16:57:38
2012
@@ -0,0 +1,13 @@
+DROP VIEW testView;
+CREATE VIEW testView as SELECT * FROM srcpart;
+DESCRIBE FORMATTED testView;
+
+ALTER VIEW testView AS SELECT value FROM src WHERE key=86;
+DESCRIBE FORMATTED testView;
+
+ALTER VIEW testView AS
+SELECT * FROM src
+WHERE key > 80 AND key < 100
+ORDER BY key, value
+LIMIT 10;
+DESCRIBE FORMATTED testView;

Added: hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_not_exist.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_not_exist.q.out?rev=1425755&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_not_exist.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_not_exist.q.out Tue
Dec 25 16:57:38 2012
@@ -0,0 +1,6 @@
+PREHOOK: query: DROP VIEW testView
+PREHOOK: type: DROPVIEW
+POSTHOOK: query: DROP VIEW testView
+POSTHOOK: type: DROPVIEW
+FAILED: SemanticException [Error 10216]: Cannot ALTER VIEW AS SELECT if view currently does
not exist
+ The following view does not exist: testView

Added: hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_with_partition.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_with_partition.q.out?rev=1425755&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_with_partition.q.out
(added)
+++ hive/trunk/ql/src/test/results/clientnegative/alter_view_as_select_with_partition.q.out
Tue Dec 25 16:57:38 2012
@@ -0,0 +1,67 @@
+PREHOOK: query: CREATE VIEW testViewPart PARTITIONED ON (value)
+AS
+SELECT key, value
+FROM src
+WHERE key=86
+PREHOOK: type: CREATEVIEW
+#### A masked pattern was here ####
+POSTHOOK: query: CREATE VIEW testViewPart PARTITIONED ON (value)
+AS
+SELECT key, value
+FROM src
+WHERE key=86
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Output: default@testViewPart
+#### A masked pattern was here ####
+PREHOOK: query: ALTER VIEW testViewPart 
+ADD PARTITION (value='val_86') PARTITION (value='val_xyz')
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@src
+PREHOOK: Input: default@testviewpart
+POSTHOOK: query: ALTER VIEW testViewPart 
+ADD PARTITION (value='val_86') PARTITION (value='val_xyz')
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@src
+POSTHOOK: Input: default@testviewpart
+POSTHOOK: Output: default@testviewpart@value=val_86
+POSTHOOK: Output: default@testviewpart@value=val_xyz
+PREHOOK: query: DESCRIBE FORMATTED testViewPart
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: DESCRIBE FORMATTED testViewPart
+POSTHOOK: type: DESCTABLE
+# col_name            	data_type           	comment             
+	 	 
+key                 	string              	None                
+	 	 
+# Partition Information	 	 
+# col_name            	data_type           	comment             
+	 	 
+value               	string              	None                
+	 	 
+# Detailed Table Information	 	 
+Database:           	default             	 
+#### A masked pattern was here ####
+Protect Mode:       	None                	 
+Retention:          	0                   	 
+Table Type:         	VIRTUAL_VIEW        	 
+Table Parameters:	 	 
+#### A masked pattern was here ####
+	 	 
+# Storage Information	 	 
+SerDe Library:      	null                	 
+InputFormat:        	org.apache.hadoop.mapred.SequenceFileInputFormat	 
+OutputFormat:       	org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat	 
+Compressed:         	No                  	 
+Num Buckets:        	-1                  	 
+Bucket Columns:     	[]                  	 
+Sort Columns:       	[]                  	 
+	 	 
+# View Information	 	 
+View Original Text: 	SELECT key, value	 
+FROM src	 	 
+WHERE key=86	 	 
+View Expanded Text: 	SELECT `src`.`key`, `src`.`value`	 
+FROM `default`.`src`	 	 
+WHERE `src`.`key`=86	 	 
+FAILED: SemanticException [Error 10217]: Cannot replace a view with CREATE VIEW or REPLACE
VIEW or ALTER VIEW AS SELECT if the view has paritions
+ The following view has partition, it could not be replaced: testViewPart

Modified: hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view1.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view1.q.out?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view1.q.out (original)
+++ hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view1.q.out Tue Dec 25
16:57:38 2012
@@ -20,8 +20,5 @@ POSTHOOK: query: alter view v add partit
 POSTHOOK: type: ALTERTABLE_ADDPARTS
 POSTHOOK: Input: default@v
 POSTHOOK: Output: default@v@ds=1/hr=2
-PREHOOK: query: create or replace view v as select * from srcpart
-PREHOOK: type: CREATEVIEW
-#### A masked pattern was here ####
-FAILED: Error in metadata: Cannot add or drop partition columns with CREATE OR REPLACE VIEW
if partitions currently exist
-FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
+FAILED: SemanticException [Error 10217]: Cannot replace a view with CREATE VIEW or REPLACE
VIEW or ALTER VIEW AS SELECT if the view has paritions
+ The following view has partition, it could not be replaced: v

Modified: hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view2.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view2.q.out?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view2.q.out (original)
+++ hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view2.q.out Tue Dec 25
16:57:38 2012
@@ -20,8 +20,5 @@ POSTHOOK: query: alter view v add partit
 POSTHOOK: type: ALTERTABLE_ADDPARTS
 POSTHOOK: Input: default@v
 POSTHOOK: Output: default@v@ds=1/hr=2
-PREHOOK: query: create or replace view v partitioned on (hr) as select * from srcpart
-PREHOOK: type: CREATEVIEW
-#### A masked pattern was here ####
-FAILED: Error in metadata: Cannot add or drop partition columns with CREATE OR REPLACE VIEW
if partitions currently exist
-FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
+FAILED: SemanticException [Error 10217]: Cannot replace a view with CREATE VIEW or REPLACE
VIEW or ALTER VIEW AS SELECT if the view has paritions
+ The following view has partition, it could not be replaced: v

Modified: hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view3.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view3.q.out?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view3.q.out (original)
+++ hive/trunk/ql/src/test/results/clientnegative/create_or_replace_view3.q.out Tue Dec 25
16:57:38 2012
@@ -1,7 +1,2 @@
-PREHOOK: query: -- Existing table is not a view
-
-create or replace view src as select ds, hr from srcpart
-PREHOOK: type: CREATEVIEW
-#### A masked pattern was here ####
-FAILED: Error in metadata: Existing table is not a view
-FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
+FAILED: SemanticException [Error 10218]: Existing table is not a view
+ The following is an existing table, not a view: src

Added: hive/trunk/ql/src/test/results/clientpositive/alter_view_as_select.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/alter_view_as_select.q.out?rev=1425755&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/alter_view_as_select.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/alter_view_as_select.q.out Tue Dec 25 16:57:38
2012
@@ -0,0 +1,130 @@
+PREHOOK: query: DROP VIEW testView
+PREHOOK: type: DROPVIEW
+POSTHOOK: query: DROP VIEW testView
+POSTHOOK: type: DROPVIEW
+PREHOOK: query: CREATE VIEW testView as SELECT * FROM srcpart
+PREHOOK: type: CREATEVIEW
+#### A masked pattern was here ####
+POSTHOOK: query: CREATE VIEW testView as SELECT * FROM srcpart
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Output: default@testView
+#### A masked pattern was here ####
+PREHOOK: query: DESCRIBE FORMATTED testView
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: DESCRIBE FORMATTED testView
+POSTHOOK: type: DESCTABLE
+# col_name            	data_type           	comment             
+	 	 
+key                 	string              	None                
+value               	string              	None                
+ds                  	string              	None                
+hr                  	string              	None                
+	 	 
+# Detailed Table Information	 	 
+Database:           	default             	 
+#### A masked pattern was here ####
+Protect Mode:       	None                	 
+Retention:          	0                   	 
+Table Type:         	VIRTUAL_VIEW        	 
+Table Parameters:	 	 
+#### A masked pattern was here ####
+	 	 
+# Storage Information	 	 
+SerDe Library:      	null                	 
+InputFormat:        	org.apache.hadoop.mapred.SequenceFileInputFormat	 
+OutputFormat:       	org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat	 
+Compressed:         	No                  	 
+Num Buckets:        	-1                  	 
+Bucket Columns:     	[]                  	 
+Sort Columns:       	[]                  	 
+	 	 
+# View Information	 	 
+View Original Text: 	SELECT * FROM srcpart	 
+View Expanded Text: 	SELECT `srcpart`.`key`, `srcpart`.`value`, `srcpart`.`ds`, `srcpart`.`hr`
FROM `default`.`srcpart`	 
+PREHOOK: query: ALTER VIEW testView AS SELECT value FROM src WHERE key=86
+PREHOOK: type: CREATEVIEW
+#### A masked pattern was here ####
+POSTHOOK: query: ALTER VIEW testView AS SELECT value FROM src WHERE key=86
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Output: default@testview
+#### A masked pattern was here ####
+PREHOOK: query: DESCRIBE FORMATTED testView
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: DESCRIBE FORMATTED testView
+POSTHOOK: type: DESCTABLE
+# col_name            	data_type           	comment             
+	 	 
+value               	string              	None                
+	 	 
+# Detailed Table Information	 	 
+Database:           	default             	 
+#### A masked pattern was here ####
+Protect Mode:       	None                	 
+Retention:          	0                   	 
+Table Type:         	VIRTUAL_VIEW        	 
+Table Parameters:	 	 
+#### A masked pattern was here ####
+	 	 
+# Storage Information	 	 
+SerDe Library:      	null                	 
+InputFormat:        	org.apache.hadoop.mapred.SequenceFileInputFormat	 
+OutputFormat:       	org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat	 
+Compressed:         	No                  	 
+Num Buckets:        	-1                  	 
+Bucket Columns:     	[]                  	 
+Sort Columns:       	[]                  	 
+	 	 
+# View Information	 	 
+View Original Text: 	SELECT value FROM src WHERE key=86	 
+View Expanded Text: 	SELECT `src`.`value` FROM `default`.`src` WHERE `src`.`key`=86	 
+PREHOOK: query: ALTER VIEW testView AS
+SELECT * FROM src
+WHERE key > 80 AND key < 100
+ORDER BY key, value
+LIMIT 10
+PREHOOK: type: CREATEVIEW
+#### A masked pattern was here ####
+POSTHOOK: query: ALTER VIEW testView AS
+SELECT * FROM src
+WHERE key > 80 AND key < 100
+ORDER BY key, value
+LIMIT 10
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Output: default@testview
+#### A masked pattern was here ####
+PREHOOK: query: DESCRIBE FORMATTED testView
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: DESCRIBE FORMATTED testView
+POSTHOOK: type: DESCTABLE
+# col_name            	data_type           	comment             
+	 	 
+key                 	string              	None                
+value               	string              	None                
+	 	 
+# Detailed Table Information	 	 
+Database:           	default             	 
+#### A masked pattern was here ####
+Protect Mode:       	None                	 
+Retention:          	0                   	 
+Table Type:         	VIRTUAL_VIEW        	 
+Table Parameters:	 	 
+#### A masked pattern was here ####
+	 	 
+# Storage Information	 	 
+SerDe Library:      	null                	 
+InputFormat:        	org.apache.hadoop.mapred.SequenceFileInputFormat	 
+OutputFormat:       	org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat	 
+Compressed:         	No                  	 
+Num Buckets:        	-1                  	 
+Bucket Columns:     	[]                  	 
+Sort Columns:       	[]                  	 
+	 	 
+# View Information	 	 
+View Original Text: 	SELECT * FROM src	 
+WHERE key > 80 AND key < 100	 	 
+ORDER BY key, value	 	 
+LIMIT 10	 	 
+View Expanded Text: 	SELECT `src`.`key`, `src`.`value` FROM `default`.`src`	 
+WHERE `src`.`key` > 80 AND `src`.`key` < 100	 	 
+ORDER BY `src`.`key`, `src`.`value`	 	 
+LIMIT 10	 	 

Modified: hive/trunk/ql/src/test/results/clientpositive/create_view.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/create_view.q.out?rev=1425755&r1=1425754&r2=1425755&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/create_view.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/create_view.q.out Tue Dec 25 16:57:38 2012
@@ -161,6 +161,7 @@ STAGE PLANS:
       Create View Operator:
         Create View
           if not exists: false
+          is alter view as select: false
           or replace: false
           columns: valoo string
           expanded text: SELECT `_c0` AS `valoo` FROM (SELECT upper(`src`.`value`) FROM `default`.`src`
WHERE `src`.`key`=86) `view0`



Mime
View raw message