You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2014/03/13 00:06:46 UTC

svn commit: r1576985 - in /hive/trunk: hcatalog/src/test/e2e/templeton/tests/ddl.conf ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java

Author: hashutosh
Date: Wed Mar 12 23:06:46 2014
New Revision: 1576985

URL: http://svn.apache.org/r1576985
Log:
HIVE-6607 : describe extended on a view fails with NPE (Eugene Koifman via Ashutosh Chauhan)

Modified:
    hive/trunk/hcatalog/src/test/e2e/templeton/tests/ddl.conf
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java

Modified: hive/trunk/hcatalog/src/test/e2e/templeton/tests/ddl.conf
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/src/test/e2e/templeton/tests/ddl.conf?rev=1576985&r1=1576984&r2=1576985&view=diff
==============================================================================
--- hive/trunk/hcatalog/src/test/e2e/templeton/tests/ddl.conf (original)
+++ hive/trunk/hcatalog/src/test/e2e/templeton/tests/ddl.conf Wed Mar 12 23:06:46 2014
@@ -1113,7 +1113,60 @@ $cfg = 
   ]
 
 }
-
+,
+  {
+    'name' => 'TEST_VIEW',
+    'tests' =>
+    [
+      {
+        'num' => 1,
+        'method' => 'POST',
+        'url' => ':TEMPLETON_URL:/templeton/v1/ddl?user.name=:UNAME:',
+        'status_code' => 200,
+        'post_options' => ['exec=DROP VIEW url_table_view;'],
+        'json_field_substr_match' => {'stderr' => 'OK', 'exitcode' => '^0$'}
+      },
+      {
+        'num' => 2,
+        'method' => 'DELETE',
+        'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/url_table?user.name=:UNAME:&ifExists=true',
+        'status_code' => 200,
+        'json_field_substr_match' => {'database' => 'default',  'table' => 'url_table'},
+      },
+      {
+               #create table
+        'num' => 3,
+        'method' => 'PUT',
+        'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/url_table?user.name=:UNAME:',
+        'format_header' => 'Content-Type: application/json',
+        'post_options' => ['{
+          "columns": [
+            { "name" : "count", "type" : "int" },
+            { "name" : "page_url", "type" : "string"}
+          ], 
+          "format" : {  "storedAs" : "SEQUENCEFILE"} 
+        }'],
+        'status_code' => 200,
+        'json_field_substr_match' => {'database' => 'default',  'table' => 'url_table'},
+      
+      },
+    {
+                                #create view
+     'num' => 4,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl?user.name=:UNAME:',
+     'status_code' => 200,
+     'post_options' => ['exec=CREATE VIEW url_table_view(url) as  SELECT DISTINCT page_url from url_table;'],
+     'json_field_substr_match' => {'stderr' => 'OK', 'exitcode' => '^0$'}
+    },
+    {
+      'num' => 5,
+      'method' => 'GET',
+      'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/url_table_view?user.name=:UNAME:&format=extended',
+      'status_code' => 200,
+    }
+    ]
+  }
 
 
 

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java?rev=1576985&r1=1576984&r2=1576985&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java Wed Mar 12 23:06:46 2014
@@ -35,6 +35,7 @@ import org.apache.hadoop.fs.FileStatus;
 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.TableType;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.ql.metadata.Hive;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -189,9 +190,11 @@ public class JsonMetaDataFormatter imple
     if (tbl.isPartitioned()) {
       builder.put("partitionColumns", makeColsUnformatted(tbl.getPartCols()));
     }
-
-    putFileSystemsStats(builder, makeTableStatusLocations(tbl, db, par),
+    if(tbl.getTableType() != TableType.VIRTUAL_VIEW) {
+      //tbl.getPath() is null for views
+      putFileSystemsStats(builder, makeTableStatusLocations(tbl, db, par),
         conf, tbl.getPath());
+    }
 
     return builder.build();
   }
@@ -222,6 +225,10 @@ public class JsonMetaDataFormatter imple
     return locations;
   }
 
+  /**
+   * @param tblPath not NULL
+   * @throws IOException
+   */
   // Duplicates logic in TextMetaDataFormatter
   private void putFileSystemsStats(MapBuilder builder, List<Path> locations,
       HiveConf conf, Path tblPath)