You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ni...@apache.org on 2017/01/06 14:14:47 UTC

ambari git commit: AMBARI-19362 : hive view 2.0 added REST endpoint for delete table functionality (nitirajrathore)

Repository: ambari
Updated Branches:
  refs/heads/trunk a5a105b40 -> 2042657e3


AMBARI-19362 : hive view 2.0 added REST endpoint for delete table functionality (nitirajrathore)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2042657e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2042657e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2042657e

Branch: refs/heads/trunk
Commit: 2042657e3e2fefc132610391ad88f94cd6efe06e
Parents: a5a105b
Author: Nitiraj Rathore <ni...@gmail.com>
Authored: Fri Jan 6 19:43:39 2017 +0530
Committer: Nitiraj Rathore <ni...@gmail.com>
Committed: Fri Jan 6 19:44:23 2017 +0530

----------------------------------------------------------------------
 .../generators/RenameTableQueryGenerator.java   |  85 +++++
 .../view/hive20/resources/browser/DDLProxy.java |  31 ++
 .../hive20/resources/browser/DDLService.java    |  23 +-
 .../RenameTableQueryGeneratorSpecTest.groovy    | 104 ++++++
 .../HIVE20_ENVIRONMENT.postman_environment.json |  16 +
 .../rest/postman/hive2.postman_collection.json  | 107 ------
 .../rest/postman/hive20.postman_collection.json | 359 +++++++++++++++++++
 7 files changed, 617 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGenerator.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGenerator.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGenerator.java
new file mode 100644
index 0000000..3406b80
--- /dev/null
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGenerator.java
@@ -0,0 +1,85 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.view.hive20.internal.query.generators;
+
+import com.google.common.base.Optional;
+import org.apache.ambari.view.hive20.exceptions.ServiceException;
+import org.apache.parquet.Strings;
+
+public class RenameTableQueryGenerator implements QueryGenerator {
+  private String oldDatabaseName;
+  private final String oldTableName;
+  private final String newDatabaseName;
+  private final String newTableName;
+
+  public RenameTableQueryGenerator(String oldDatabaseName, String oldTableName, String newDatabaseName, String newTableName) {
+    this.oldDatabaseName = oldDatabaseName;
+    this.oldTableName = oldTableName;
+    this.newDatabaseName = newDatabaseName;
+    this.newTableName = newTableName;
+  }
+
+  public String getOldDatabaseName() {
+    return oldDatabaseName;
+  }
+
+  public String getOldTableName() {
+    return oldTableName;
+  }
+
+  public String getNewDatabaseName() {
+    return newDatabaseName;
+  }
+
+  public String getNewTableName() {
+    return newTableName;
+  }
+
+  /**
+   * ALTER TABLE table_name RENAME TO new_table_name;
+   * @return Optional rename query if table has changed.
+   * @throws ServiceException
+   */
+  @Override
+  public Optional<String> getQuery() throws ServiceException {
+    StringBuilder queryBuilder = new StringBuilder("ALTER TABLE `");
+    if(!Strings.isNullOrEmpty(this.getOldDatabaseName())){
+      queryBuilder.append(this.getOldDatabaseName().trim()).append(".");
+    }
+    if(!Strings.isNullOrEmpty(this.getOldTableName())){
+      queryBuilder.append(this.getOldTableName().trim());
+    }else{
+      throw new ServiceException("current table name cannot be null or empty.");
+    }
+    queryBuilder.append("` RENAME TO `");
+
+    if(!Strings.isNullOrEmpty(this.getNewDatabaseName())){
+      queryBuilder.append(this.getNewDatabaseName().trim()).append(".");
+    }
+
+    if(!Strings.isNullOrEmpty(this.getNewTableName())){
+      queryBuilder.append(this.getNewTableName().trim());
+    }else{
+      throw new ServiceException("new table name cannot be null or empty.");
+    }
+
+    queryBuilder.append("`");
+    return Optional.of(queryBuilder.toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLProxy.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLProxy.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLProxy.java
index 5a2d389..8c37a96 100644
--- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLProxy.java
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLProxy.java
@@ -43,6 +43,7 @@ import org.apache.ambari.view.hive20.internal.parsers.TableMetaParserImpl;
 import org.apache.ambari.view.hive20.internal.query.generators.AlterTableQueryGenerator;
 import org.apache.ambari.view.hive20.internal.query.generators.CreateTableQueryGenerator;
 import org.apache.ambari.view.hive20.internal.query.generators.DeleteTableQueryGenerator;
+import org.apache.ambari.view.hive20.internal.query.generators.RenameTableQueryGenerator;
 import org.apache.ambari.view.hive20.resources.jobs.JobServiceInternal;
 import org.apache.ambari.view.hive20.resources.jobs.viewJobs.Job;
 import org.apache.ambari.view.hive20.resources.jobs.viewJobs.JobController;
@@ -299,4 +300,34 @@ public class DDLProxy {
       throw new ServiceException("Failed to generate alter table query for table " + oldTableMeta.getDatabase() + "." + oldTableMeta.getTable());
     }
   }
+
+  public Job renameTable(String oldDatabaseName, String oldTableName, String newDatabaseName, String newTableName,
+                         JobResourceManager resourceManager)
+    throws ServiceException {
+    RenameTableQueryGenerator queryGenerator = new RenameTableQueryGenerator(oldDatabaseName, oldTableName,
+      newDatabaseName, newTableName);
+    Optional<String> renameTable = queryGenerator.getQuery();
+    if(renameTable.isPresent()) {
+      String renameQuery = renameTable.get();
+      LOG.info("Creating job for : {}", renameQuery);
+      Map jobInfo = new HashMap<>();
+      jobInfo.put("title", "Rename table " + oldDatabaseName + "." + oldTableName + " to " + newDatabaseName + "." + newTableName);
+      jobInfo.put("forcedContent", renameQuery);
+      jobInfo.put("dataBase", oldDatabaseName);
+
+      try {
+        Job job = new JobImpl(jobInfo);
+        JobController createdJobController = new JobServiceInternal().createJob(job, resourceManager);
+        Job returnableJob = createdJobController.getJobPOJO();
+        LOG.info("returning job with id {} for rename table {}", returnableJob.getId(), oldTableName);
+        return returnableJob;
+      } catch (Throwable e) {
+        LOG.error("Exception occurred while renaming the table for rename Query : {}", renameQuery, e);
+        throw new ServiceException(e);
+      }
+    }else{
+      throw new ServiceException("Failed to generate rename table query for table " + oldDatabaseName + "." +
+        oldTableName);
+    }
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLService.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLService.java
index 3d4e7d7..b278983 100644
--- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLService.java
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/browser/DDLService.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
 import javax.inject.Inject;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
@@ -120,6 +121,25 @@ public class DDLService extends BaseService {
     }
   }
 
+  @PUT
+  @Path("databases/{database_id}/tables/{table_id}/rename")
+  @Produces(MediaType.APPLICATION_JSON)
+  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+  public Response renameTable(@PathParam("database_id") String oldDatabaseName, @PathParam("table_id") String oldTableName,
+                              @FormParam("new_database_id") String newDatabaseName, @FormParam("new_table_id")
+                                  String newTableName) {
+    try {
+      Job job = proxy.renameTable(oldDatabaseName, oldTableName, newDatabaseName, newTableName, getResourceManager());
+      JSONObject response = new JSONObject();
+      response.put("job", job);
+      return Response.status(Response.Status.ACCEPTED).entity(response).build();
+    } catch (ServiceException e) {
+      LOG.error("Exception occurred while renaming table for oldDatabaseName {}, oldTableName: {}, newDatabaseName : {}," +
+        " newTableName : {}", oldDatabaseName, oldTableName, newDatabaseName, newTableName, e);
+      throw new ServiceFormattedException(e);
+    }
+  }
+
   @POST
   @Path("databases/{database_id}/tables/ddl")
   @Produces(MediaType.APPLICATION_JSON)
@@ -130,7 +150,8 @@ public class DDLService extends BaseService {
       if (queryType.equals(CREATE_TABLE)) {
         query = proxy.generateCreateTableDDL(request.tableInfo.getDatabase(), request.tableInfo);
       }else if(queryType.equals(ALTER_TABLE)){
-        query = proxy.generateAlterTableQuery(context, getHiveConnectionConfig(), request.tableInfo.getDatabase(), request.tableInfo.getTable(), request.tableInfo);
+        query = proxy.generateAlterTableQuery(context, getHiveConnectionConfig(), request.tableInfo.getDatabase(),
+                request.tableInfo.getTable(), request.tableInfo);
       }else{
         throw new ServiceException("query_type = '" + queryType + "' is not supported");
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/test/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGeneratorSpecTest.groovy
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/test/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGeneratorSpecTest.groovy b/contrib/views/hive20/src/test/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGeneratorSpecTest.groovy
new file mode 100644
index 0000000..cce9e6c
--- /dev/null
+++ b/contrib/views/hive20/src/test/java/org/apache/ambari/view/hive20/internal/query/generators/RenameTableQueryGeneratorSpecTest.groovy
@@ -0,0 +1,104 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.view.hive20.internal.query.generators
+
+import org.apache.ambari.view.hive20.exceptions.ServiceException
+import spock.lang.Specification
+
+public class RenameTableQueryGeneratorSpecTest extends Specification{
+
+  def "rename simple query"(){
+    setup:
+    def  renameTable = new RenameTableQueryGenerator("d1", "tab1", "d2", "tab2")
+
+    when:
+    def query = renameTable.getQuery()
+
+    then:
+      query.isPresent()
+
+    when:
+    def hiveQuery = query.get();
+
+    then:
+    with(hiveQuery){
+      hiveQuery == "ALTER TABLE `d1.tab1` RENAME TO `d2.tab2`"
+    }
+  }
+
+  def "rename without old database query"(){
+    setup:
+    def  renameTable = new RenameTableQueryGenerator(null, "tab1", "d2", "tab2")
+
+    when:
+    def query = renameTable.getQuery()
+
+    then:
+      query.isPresent()
+
+    when:
+    def hiveQuery = query.get();
+
+    then:
+    with(hiveQuery){
+      hiveQuery == "ALTER TABLE `tab1` RENAME TO `d2.tab2`"
+    }
+  }
+
+  def "rename without old and new database query"(){
+    setup:
+    def  renameTable = new RenameTableQueryGenerator(null, "tab1", "", "tab2")
+
+    when:
+    def query = renameTable.getQuery()
+
+    then:
+      query.isPresent()
+
+    when:
+    def hiveQuery = query.get();
+
+    then:
+    with(hiveQuery){
+      hiveQuery == "ALTER TABLE `tab1` RENAME TO `tab2`"
+    }
+  }
+
+  def "rename with empty old tablename throws exception"(){
+    setup:
+    def  renameTable = new RenameTableQueryGenerator("d1", "", "d2", "tab2")
+
+    when:
+    def query = renameTable.getQuery()
+
+    then:
+      thrown(ServiceException)
+  }
+
+  def "rename with null new tablename throws exception"(){
+    setup:
+    def  renameTable = new RenameTableQueryGenerator("d1", "tab1", "d2", null)
+
+    when:
+    def query = renameTable.getQuery()
+
+    then:
+      thrown(ServiceException)
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/test/rest/postman/HIVE20_ENVIRONMENT.postman_environment.json
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/test/rest/postman/HIVE20_ENVIRONMENT.postman_environment.json b/contrib/views/hive20/src/test/rest/postman/HIVE20_ENVIRONMENT.postman_environment.json
new file mode 100644
index 0000000..ce7acda
--- /dev/null
+++ b/contrib/views/hive20/src/test/rest/postman/HIVE20_ENVIRONMENT.postman_environment.json
@@ -0,0 +1,16 @@
+{
+  "id": "d8ebef41-e2ff-6326-eb88-7c44b262d1b6",
+  "name": "HIVE20_ENVIRONMENT",
+  "values": [
+    {
+      "key": "APP_BASE_URL",
+      "value": "http://c6401.ambari.apache.org:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE",
+      "type": "text",
+      "enabled": true
+    }
+  ],
+  "timestamp": 1483525025492,
+  "_postman_variable_scope": "environment",
+  "_postman_exported_at": "2017-01-04T10:23:26.156Z",
+  "_postman_exported_using": "Postman/4.9.2"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/test/rest/postman/hive2.postman_collection.json
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/test/rest/postman/hive2.postman_collection.json b/contrib/views/hive20/src/test/rest/postman/hive2.postman_collection.json
deleted file mode 100644
index c7ce0c9..0000000
--- a/contrib/views/hive20/src/test/rest/postman/hive2.postman_collection.json
+++ /dev/null
@@ -1,107 +0,0 @@
-{
-	"variables": [],
-	"info": {
-		"name": "hive2",
-		"_postman_id": "d3d966bf-9112-9017-908b-7bc820a5a962",
-		"description": "",
-		"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
-	},
-	"item": [
-		{
-			"name": "fetch  table",
-			"request": {
-				"auth": {
-					"type": "basic",
-					"basic": {
-						"username": "admin",
-						"password": "admin",
-						"saveHelperData": true,
-						"showPassword": false
-					}
-				},
-				"url": "http://c6401.ambari.apache.org:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/resources/ddl/databases/d1/tables/t2/info?_=1481634018195",
-				"method": "GET",
-				"header": [
-					{
-						"key": "X-Requested-By",
-						"value": "ambari",
-						"description": ""
-					},
-					{
-						"key": "Authorization",
-						"value": "Basic YWRtaW46YWRtaW4=",
-						"description": ""
-					}
-				],
-				"body": {},
-				"description": "fetch d1.t2 table"
-			},
-			"response": []
-		},
-		{
-			"name": "create new table table",
-			"request": {
-				"auth": {
-					"type": "basic",
-					"basic": {
-						"username": "admin",
-						"password": "admin",
-						"saveHelperData": true,
-						"showPassword": false
-					}
-				},
-				"url": "http://c6401.ambari.apache.org:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/resources/ddl/databases/d1/tables",
-				"method": "POST",
-				"header": [
-					{
-						"key": "X-Requested-By",
-						"value": "ambari",
-						"description": ""
-					},
-					{
-						"key": "Authorization",
-						"value": "Basic YWRtaW46YWRtaW4=",
-						"description": ""
-					}
-				],
-				"body": {
-					"mode": "raw",
-					"raw": "{\n    \"database\": \"d1\",\n    \"table\": \"t7\",\n    \"columns\": [\n      {\n        \"name\": \"col_name1\",\n        \"type\": \"string\",\n        \"comment\": \"col_name1 comment\"\n      },\n      {\n        \"name\": \"col_name2\",\n        \"type\": \"decimal(10,2)\",\n        \"comment\": \"col_name2 comment\"\n      }\n    ],\n    \"ddl\": \"CREATE TABLE `t2`(\\n  `col_name1` string COMMENT 'col_name1 comment', \\n  `col_name2` decimal(10,2) COMMENT 'col_name2 comment')\\nCOMMENT 'table t1 comment'\\nPARTITIONED BY ( \\n  `col_name3` string COMMENT 'col_name3 comment', \\n  `col_name4` char(1) COMMENT 'col_name4 comment')\\nCLUSTERED BY ( \\n  col_name1, \\n  col_name2) \\nSORTED BY ( \\n  col_name1 ASC, \\n  col_name2 DESC) \\nINTO 5 BUCKETS\\nROW FORMAT DELIMITED \\n  FIELDS TERMINATED BY ',' \\nWITH SERDEPROPERTIES ( \\n  'escape.delim'='\\\\\\\\') \\nSTORED AS INPUTFORMAT \\n  'org.apache.hadoop.mapred.SequenceFileInputFormat' \\nOUTPUTFORMAT \\n  'or
 g.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat'\\nLOCATION\\n  'hdfs://c6401.ambari.apache.org:8020/user/hive/tables/d1/t1'\\nTBLPROPERTIES (\\n  'NO_AUTO_COMPACTION'='true', \\n  'immutable'='false', \\n  'orc.compress'='SNAPPY', \\n  'transient_lastDdlTime'='1481520077')\\n\",\n    \"partitionInfo\": {\n      \"columns\": [\n        {\n          \"name\": \"col_name4\",\n          \"type\": \"char(1)\",\n          \"comment\": \"col_name4 comment\"\n        },\n        {\n          \"name\": \"col_name3\",\n          \"type\": \"string\",\n          \"comment\": \"col_name3 comment\"\n        }\n      ]\n    },\n    \"detailedInfo\": {\n      \"dbName\": \"d1\",\n      \"owner\": \"admin\",\n      \"createTime\": \"Mon Dec 12 05:21:17 UTC 2016\",\n      \"lastAccessTime\": \"UNKNOWN\",\n      \"retention\": \"0\",\n      \"tableType\": \"MANAGED_TABLE\",\n      \"location\": \"hdfs://c6401.ambari.apache.org:8020/user/hive/tables/d1/t1\",\n      \"parameters\": {\n        
 \"immutable\": \"false\",\n        \"orc.compress\": \"SNAPPY\",\n        \"transient_lastDdlTime\": \"1481520077\",\n        \"NO_AUTO_COMPACTION\": \"true\",\n        \"comment\": \"table t1 comment\",\n        \"SORTBUCKETCOLSPREFIX\": \"TRUE\"\n      }\n    },\n    \"storageInfo\": {\n      \"serdeLibrary\": \"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe\",\n      \"inputFormat\": \"org.apache.hadoop.mapred.SequenceFileInputFormat\",\n      \"outputFormat\": \"org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat\",\n      \"compressed\": \"No\",\n      \"numBuckets\": \"5\",\n      \"bucketCols\": [\n        \"col_name1\",\n        \" col_name2\"\n      ],\n      \"sortCols\": [\n        {\n          \"columnName\": \"col_name1\",\n          \"order\": \"ASC\"\n        },\n        {\n          \"columnName\": \"col_name2\",\n          \"order\": \"DESC\"\n        }\n      ],\n      \"parameters\": {\n        \"escape.delim\": \"\\\\\\\\\",\n        \"field.delim\": \"
 ,\",\n        \"serialization.format\": \",\"\n      }\n    }\n  }"
-				},
-				"description": "create new table table"
-			},
-			"response": []
-		},
-		{
-			"name": "delete  table",
-			"request": {
-				"auth": {
-					"type": "basic",
-					"basic": {
-						"username": "admin",
-						"password": "admin",
-						"saveHelperData": true,
-						"showPassword": false
-					}
-				},
-				"url": "http://c6401.ambari.apache.org:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/resources/ddl/databases/d1/tables/t9",
-				"method": "DELETE",
-				"header": [
-					{
-						"key": "X-Requested-By",
-						"value": "ambari",
-						"description": ""
-					},
-					{
-						"key": "Authorization",
-						"value": "Basic YWRtaW46YWRtaW4=",
-						"description": ""
-					}
-				],
-				"body": {},
-				"description": "delete d1.t2 table"
-			},
-			"response": []
-		}
-	]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/2042657e/contrib/views/hive20/src/test/rest/postman/hive20.postman_collection.json
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/test/rest/postman/hive20.postman_collection.json b/contrib/views/hive20/src/test/rest/postman/hive20.postman_collection.json
new file mode 100644
index 0000000..b6d84b3
--- /dev/null
+++ b/contrib/views/hive20/src/test/rest/postman/hive20.postman_collection.json
@@ -0,0 +1,359 @@
+{
+	"variables": [],
+	"info": {
+		"name": "hive20",
+		"_postman_id": "6dddb63b-c935-0982-65dc-4b9542ac8074",
+		"description": "REST call tests examples for hive 2.0",
+		"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
+	},
+	"item": [
+		{
+			"name": "fetch  table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables/t1/info?_=1481634018195",
+				"method": "GET",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					}
+				],
+				"body": {},
+				"description": "fetch d1.t2 table"
+			},
+			"response": []
+		},
+		{
+			"name": "create new table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables",
+				"method": "POST",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/json",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\t\"tableInfo\" : {\n    \"database\": \"d1\",\n    \"table\": \"t11\",\n    \"columns\": [\n      {\n        \"name\": \"col_name1\",\n        \"type\": \"string\",\n        \"comment\": \"col_name1 comment\"\n      },\n      {\n        \"name\": \"col_name2\",\n        \"type\": \"decimal(10,2)\",\n        \"comment\": \"col_name2 comment\"\n      }\n    ],\n    \"partitionInfo\": {\n      \"columns\": [\n        {\n          \"name\": \"col_name4\",\n          \"type\": \"char(1)\",\n          \"comment\": \"col_name4 comment\"\n        },\n        {\n          \"name\": \"col_name3\",\n          \"type\": \"string\",\n          \"comment\": \"col_name3 comment\"\n        }\n      ]\n    },\n    \"detailedInfo\": {\n      \"dbName\": \"d1\",\n      \"owner\": \"admin\",\n      \"createTime\": \"Mon Dec 12 05:21:17 UTC 2016\",\n      \"lastAccessTime\": \"UNKNOWN\",\n      \"retention\": \"0\",\n      \"tableType\": \"MANAGED_TABLE\",\n      \"location\": \"hdfs://
 c6401.ambari.apache.org:8020/user/hive/tables/d1/t1\",\n      \"parameters\": {\n        \"immutable\": \"false\",\n        \"orc.compress\": \"SNAPPY\",\n        \"transient_lastDdlTime\": \"1481520077\",\n        \"NO_AUTO_COMPACTION\": \"true\",\n        \"comment\": \"table t1 comment\",\n        \"SORTBUCKETCOLSPREFIX\": \"TRUE\"\n      }\n    },\n    \"storageInfo\": {\n      \"serdeLibrary\": \"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe\",\n      \"inputFormat\": \"org.apache.hadoop.mapred.SequenceFileInputFormat\",\n      \"outputFormat\": \"org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat\",\n      \"compressed\": \"No\",\n      \"numBuckets\": \"5\",\n      \"bucketCols\": [\n        \"col_name1\",\n        \" col_name2\"\n      ],\n      \"sortCols\": [\n        {\n          \"columnName\": \"col_name1\",\n          \"order\": \"ASC\"\n        },\n        {\n          \"columnName\": \"col_name2\",\n          \"order\": \"DESC\"\n        }\n      ],\n    
   \"parameters\": {\n        \"escape.delim\": \"\\\\\\\\\",\n        \"field.delim\": \",\",\n        \"serialization.format\": \",\"\n      }\n    }\n  }\n}"
+				},
+				"description": "create new table "
+			},
+			"response": []
+		},
+		{
+			"name": "delete  table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables/t11",
+				"method": "DELETE",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					}
+				],
+				"body": {},
+				"description": "delete d1.t2 table"
+			},
+			"response": []
+		},
+		{
+			"name": "ddl for create new table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables/ddl?query_type=create-table",
+				"method": "POST",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/json",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\"tableInfo\" : {\n    \"database\": \"d1\",\n    \"table\": \"t7\",\n    \"columns\": [\n      {\n        \"name\": \"col_name1\",\n        \"type\": \"string\",\n        \"comment\": \"col_name1 comment\"\n      },\n      {\n        \"name\": \"col_name2\",\n        \"type\": \"decimal(10,2)\",\n        \"comment\": \"col_name2 comment\"\n      }\n    ],\n    \"partitionInfo\": {\n      \"columns\": [\n        {\n          \"name\": \"col_name4\",\n          \"type\": \"char(1)\",\n          \"comment\": \"col_name4 comment\"\n        },\n        {\n          \"name\": \"col_name3\",\n          \"type\": \"string\",\n          \"comment\": \"col_name3 comment\"\n        }\n      ]\n    },\n    \"detailedInfo\": {\n      \"dbName\": \"d1\",\n      \"owner\": \"admin\",\n      \"createTime\": \"Mon Dec 12 05:21:17 UTC 2016\",\n      \"lastAccessTime\": \"UNKNOWN\",\n      \"retention\": \"0\",\n      \"tableType\": \"MANAGED_TABLE\",\n      \"location\": \"hdfs://c64
 01.ambari.apache.org:8020/user/hive/tables/d1/t1\",\n      \"parameters\": {\n        \"immutable\": \"false\",\n        \"orc.compress\": \"SNAPPY\",\n        \"transient_lastDdlTime\": \"1481520077\",\n        \"NO_AUTO_COMPACTION\": \"true\",\n        \"comment\": \"table t1 comment\",\n        \"SORTBUCKETCOLSPREFIX\": \"TRUE\"\n      }\n    },\n    \"storageInfo\": {\n      \"serdeLibrary\": \"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe\",\n      \"inputFormat\": \"org.apache.hadoop.mapred.SequenceFileInputFormat\",\n      \"outputFormat\": \"org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat\",\n      \"compressed\": \"No\",\n      \"numBuckets\": \"5\",\n      \"bucketCols\": [\n        \"col_name1\",\n        \" col_name2\"\n      ],\n      \"sortCols\": [\n        {\n          \"columnName\": \"col_name1\",\n          \"order\": \"ASC\"\n        },\n        {\n          \"columnName\": \"col_name2\",\n          \"order\": \"DESC\"\n        }\n      ],\n      \
 "parameters\": {\n        \"escape.delim\": \"\\\\\\\\\",\n        \"field.delim\": \",\",\n        \"serialization.format\": \",\"\n      }\n    }\n  }\n}"
+				},
+				"description": "generates ddl for create new table"
+			},
+			"response": []
+		},
+		{
+			"name": "ddl for alter table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables/ddl?query_type=alter-table",
+				"method": "POST",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/json",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\"tableInfo\" : {\n    \"database\": \"d1\",\n    \"table\": \"x24\",\n    \"columns\": [\n      {\n        \"name\": \"col_name1\",\n        \"type\": \"string\",\n        \"comment\": \"col_name1 comment\"\n      },\n      {\n        \"name\": \"col_name2\",\n        \"type\": \"decimal(10,2)\",\n        \"comment\": \"col_name2 comment\"\n      },\n      {\n        \"name\": \"col_name5\",\n        \"type\": \"varchar(102)\",\n        \"comment\": \"col_name_extra comment\"\n      },\n      {\n        \"name\": \"col_name_extra\",\n        \"type\": \"varchar(102)\",\n        \"comment\": \"col_name_extra comment\"\n      }\n    ],\n    \"partitionInfo\": {\n      \"columns\": [\n        {\n          \"name\": \"col_name4\",\n          \"type\": \"char(1)\",\n          \"comment\": \"col_name4 comment\"\n        },\n        {\n          \"name\": \"col_name3\",\n          \"type\": \"string\",\n          \"comment\": \"col_name3 comment\"\n        }\n      ]\n    
 },\n    \"detailedInfo\": {\n      \"dbName\": \"d1\",\n      \"owner\": \"admin\",\n      \"createTime\": \"Mon Dec 12 05:21:17 UTC 2016\",\n      \"lastAccessTime\": \"UNKNOWN\",\n      \"retention\": \"0\",\n      \"tableType\": \"MANAGED_TABLE\",\n      \"location\": \"hdfs://c6401.ambari.apache.org:8020/user/hive/tables/d1/t1\",\n      \"parameters\": {\n        \"immutable\": \"false\",\n        \"orc.compress\": \"SNAPPY\",\n        \"transient_lastDdlTime\": \"1481520077\",\n        \"NO_AUTO_COMPACTION\": \"true\",\n        \"comment\": \"table t1 comment\",\n        \"SORTBUCKETCOLSPREFIX\": \"TRUE\"\n      }\n    },\n    \"storageInfo\": {\n      \"serdeLibrary\": \"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe\",\n      \"inputFormat\": \"org.apache.hadoop.mapred.SequenceFileInputFormat\",\n      \"outputFormat\": \"org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat\",\n      \"compressed\": \"No\",\n      \"numBuckets\": \"7\",\n      \"bucketCols\": [\n    
     \"col_name1\",\n        \" col_name_extra\"\n      ],\n      \"parameters\": {\n        \"escape.delim\": \"\\\\\\\\\",\n        \"field.delim\": \",\",\n        \"serialization.format\": \",\"\n      }\n    }\n  }\n}"
+				},
+				"description": "generates ddl for alter table"
+			},
+			"response": []
+		},
+		{
+			"name": "simple create new table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables",
+				"method": "POST",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/json",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\t\"tableInfo\": {\n\t\t\"database\": \"d1\",\n\t\t\"table\": \"x25\",\n\t\t\"columns\": [{\n\t\t\t\"name\": \"c1\",\n\t\t\t\"type\": \"TINYINT\",\n\t\t\t\"comment\": \"\",\n\t\t\t\"precision\": null,\n\t\t\t\"scale\": null\n\t\t}, {\n\t\t\t\"name\": \"c4\",\n\t\t\t\"type\": \"TINYINT\",\n\t\t\t\"comment\": \"\",\n\t\t\t\"precision\": null,\n\t\t\t\"scale\": null\n\t\t}, {\n\t\t\t\"name\": \"c5\",\n\t\t\t\"type\": \"TINYINT\",\n\t\t\t\"comment\": \"\",\n\t\t\t\"precision\": null,\n\t\t\t\"scale\": null\n\t\t}],\n\t\t\"partitionInfo\": {\n\t\t\t\"columns\": [{\n\t\t\t\t\"name\": \"c2\",\n\t\t\t\t\"type\": \"TINYINT\",\n\t\t\t\t\"comment\": \"\",\n\t\t\t\t\"precision\": null,\n\t\t\t\t\"scale\": null\n\t\t\t}, {\n\t\t\t\t\"name\": \"c3\",\n\t\t\t\t\"type\": \"TINYINT\",\n\t\t\t\t\"comment\": \"\",\n\t\t\t\t\"precision\": null,\n\t\t\t\t\"scale\": null\n\t\t\t}]\n\t\t},\n\t\t\"detailedInfo\": {\n\t\t\t\n\t\t},\n\t\t\"storageInfo\": {\n\t\t\t\"fileFormat\": \"TEXTFILE\",
 \n\t\t\t\"numBuckets\": \"5\",\n\t\t\t\"bucketCols\": [\"c4\", \"c5\"]\n\t\t}\n\t}\n}"
+				},
+				"description": "create new table table"
+			},
+			"response": []
+		},
+		{
+			"name": "ddl for column alter table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables/ddl?query_type=alter-table",
+				"method": "POST",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/json",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\"tableInfo\" : {\n    \"database\": \"default\",\n    \"table\": \"table1\",\n    \"columns\": [\n      {\n        \"name\": \"col_name1\",\n        \"type\": \"string\",\n        \"comment\": \"col_name1 comment\"\n      },\n      {\n        \"name\": \"col_name2\",\n        \"type\": \"decimal(10,2)\",\n        \"comment\": \"col_name2 comment\"\n      },\n      {\n        \"name\": \"col_name3\",\n        \"type\": \"varchar(102)\",\n        \"comment\": \"col_name3 comment\"\n      },\n      {\n        \"name\": \"col_name4\",\n        \"type\": \"varchar(222)\",\n        \"comment\": \"col_name4 comment\"\n      }\n    ]\n  }\n}"
+				},
+				"description": "generates ddl for alter table"
+			},
+			"response": []
+		},
+		{
+			"name": "alter table ",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/default/tables/table1",
+				"method": "PUT",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/json",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\"tableInfo\" : {\n    \"database\": \"default\",\n    \"table\": \"table1\",\n    \"columns\": [\n      {\n        \"name\": \"col_name1\",\n        \"type\": \"string\",\n        \"comment\": \"col_name1 comment\"\n      },\n      {\n        \"name\": \"col_name2\",\n        \"type\": \"decimal(10,2)\",\n        \"comment\": \"col_name2 comment\"\n      },\n      {\n        \"name\": \"col_name3\",\n        \"type\": \"varchar(102)\",\n        \"comment\": \"col_name3 comment\"\n      },\n      {\n        \"name\": \"col_name4\",\n        \"type\": \"varchar(222)\",\n        \"comment\": \"col_name4 comment\"\n      }\n    ]\n  }\n}"
+				},
+				"description": "to alter an existing table."
+			},
+			"response": []
+		},
+		{
+			"name": "rename table",
+			"request": {
+				"auth": {
+					"type": "basic",
+					"basic": {
+						"username": "admin",
+						"password": "admin",
+						"saveHelperData": true,
+						"showPassword": false
+					}
+				},
+				"url": "{{APP_BASE_URL}}/resources/ddl/databases/d1/tables/t2/rename",
+				"method": "PUT",
+				"header": [
+					{
+						"key": "X-Requested-By",
+						"value": "ambari",
+						"description": ""
+					},
+					{
+						"key": "Authorization",
+						"value": "Basic YWRtaW46YWRtaW4=",
+						"description": ""
+					},
+					{
+						"key": "Content-Type",
+						"value": "application/x-www-form-urlencoded",
+						"description": ""
+					}
+				],
+				"body": {
+					"mode": "urlencoded",
+					"urlencoded": [
+						{
+							"key": "new_database_id",
+							"value": "default",
+							"type": "text",
+							"enabled": true
+						},
+						{
+							"key": "new_table_id",
+							"value": "t2",
+							"type": "text",
+							"enabled": true
+						}
+					]
+				},
+				"description": "RENAME TABLE"
+			},
+			"response": []
+		}
+	]
+}
\ No newline at end of file