You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by na...@apache.org on 2014/06/27 06:13:03 UTC
svn commit: r1605945 - in /hive/trunk:
hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/
ql/src/java/org/apache/hadoop/hive/ql/exec/
ql/src/java/org/apache/hadoop/hive/ql/plan/
ql/src/test/queries/clientpositive/ ql/src/test/results/clientposit...
Author: navis
Date: Fri Jun 27 04:13:03 2014
New Revision: 1605945
URL: http://svn.apache.org/r1605945
Log:
HIVE-7298 : desc database extended does not show properties of the database (Navis review by Ashutosh Chauhan)
Added:
hive/trunk/ql/src/test/queries/clientpositive/describe_database.q
hive/trunk/ql/src/test/results/clientpositive/describe_database.q.out
Modified:
hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/DescDatabaseDesc.java
hive/trunk/ql/src/test/results/clientpositive/alter_db_owner.q.out
hive/trunk/ql/src/test/results/clientpositive/authorization_owner_actions_db.q.out
hive/trunk/ql/src/test/results/clientpositive/database_location.q.out
hive/trunk/ql/src/test/results/clientpositive/database_properties.q.out
Modified: hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java?rev=1605945&r1=1605944&r2=1605945&view=diff
==============================================================================
--- hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java (original)
+++ hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java Fri Jun 27 04:13:03 2014
@@ -80,7 +80,7 @@ public class TestSemanticAnalysis extend
assertEquals(0, resp.getResponseCode());
ArrayList<String> result = new ArrayList<String>();
hcatDriver.getResults(result);
- assertTrue(result.get(0).contains("mydb.db"));
+ assertTrue(result.get(0).contains("mydb")); // location is not shown in test mode
hcatDriver.run("drop database mydb cascade");
}
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=1605945&r1=1605944&r2=1605945&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 Fri Jun 27 04:13:03 2014
@@ -1076,16 +1076,14 @@ public class DDLTask extends Task<DDLWor
switch (alterDbDesc.getAlterType()) {
case ALTER_PROPERTY:
Map<String, String> newParams = alterDbDesc.getDatabaseProperties();
- if (database != null) {
- Map<String, String> params = database.getParameters();
- // if both old and new params are not null, merge them
- if (params != null && newParams != null) {
- params.putAll(newParams);
- database.setParameters(params);
- } else { // if one of them is null, replace the old params with the new
- // one
- database.setParameters(newParams);
- }
+ Map<String, String> params = database.getParameters();
+ // if both old and new params are not null, merge them
+ if (params != null && newParams != null) {
+ params.putAll(newParams);
+ database.setParameters(params);
+ } else {
+ // if one of them is null, replace the old params with the new one
+ database.setParameters(newParams);
}
break;
@@ -2618,7 +2616,7 @@ public class DDLTask extends Task<DDLWor
* Throws this exception if an unexpected error occurs.
*/
private int showFunctions(ShowFunctionsDesc showFuncs) throws HiveException {
- // get the tables for the desired pattenn - populate the output stream
+ // get the tables for the desired patten - populate the output stream
Set<String> funcs = null;
if (showFuncs.getPattern() != null) {
LOG.info("pattern: " + showFuncs.getPattern());
@@ -3216,16 +3214,20 @@ public class DDLTask extends Task<DDLWor
if (database == null) {
throw new HiveException(ErrorMsg.DATABASE_NOT_EXISTS, descDatabase.getDatabaseName());
- } else {
- Map<String, String> params = null;
- if(descDatabase.isExt()) {
- params = database.getParameters();
- }
- PrincipalType ownerType = database.getOwnerType();
- formatter.showDatabaseDescription(outStream, database.getName(),
- database.getDescription(), database.getLocationUri(),
- database.getOwnerName(), (null == ownerType) ? null : ownerType.name(), params);
}
+ Map<String, String> params = null;
+ if (descDatabase.isExt()) {
+ params = database.getParameters();
+ }
+ String location = database.getLocationUri();
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_IN_TEST)) {
+ location = "location/in/test";
+ }
+ PrincipalType ownerType = database.getOwnerType();
+ formatter.showDatabaseDescription(outStream, database.getName(),
+ database.getDescription(), location,
+ database.getOwnerName(), (null == ownerType) ? null : ownerType.name(), params);
+
outStream.close();
outStream = null;
} catch (IOException e) {
@@ -4018,7 +4020,7 @@ public class DDLTask extends Task<DDLWor
// drop the table
db.dropTable(dropTbl.getTableName());
if (tbl != null) {
- // We have already locked the table in DDLSemenaticAnalyzer, don't do it again here
+ // We have already locked the table in DDLSemanticAnalyzer, don't do it again here
work.getOutputs().add(new WriteEntity(tbl, WriteEntity.WriteType.DDL_NO_LOCK));
}
}
@@ -4556,8 +4558,6 @@ public class DDLTask extends Task<DDLWor
/**
* Make location in specified sd qualified.
*
- * @param conf
- * Hive configuration.
* @param databaseName
* Database name.
* @param sd
@@ -4592,8 +4592,6 @@ public class DDLTask extends Task<DDLWor
/**
* Make qualified location for an index .
*
- * @param conf
- * Hive configuration.
* @param crtIndex
* Create index descriptor.
* @param name
@@ -4623,8 +4621,6 @@ public class DDLTask extends Task<DDLWor
/**
* Make qualified location for a database .
*
- * @param conf
- * Hive configuration.
* @param database
* Database.
*/
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/DescDatabaseDesc.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/DescDatabaseDesc.java?rev=1605945&r1=1605944&r2=1605945&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/DescDatabaseDesc.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/DescDatabaseDesc.java Fri Jun 27 04:13:03 2014
@@ -38,7 +38,7 @@ public class DescDatabaseDesc extends DD
/**
* thrift ddl for the result of describe database.
*/
- private static final String schema = "db_name,comment,location,parameters#string:string:string:string";
+ private static final String schema = "db_name,comment,location,owner_name,owner_type,parameters#string:string:string:string:string:string";
public DescDatabaseDesc() {
}
Added: hive/trunk/ql/src/test/queries/clientpositive/describe_database.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/describe_database.q?rev=1605945&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/describe_database.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/describe_database.q Fri Jun 27 04:13:03 2014
@@ -0,0 +1,3 @@
+create database test_db with dbproperties ('key1' = 'value1', 'key2' = 'value2');
+desc database extended test_db;
+drop database test_db;
Modified: hive/trunk/ql/src/test/results/clientpositive/alter_db_owner.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/alter_db_owner.q.out?rev=1605945&r1=1605944&r2=1605945&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/alter_db_owner.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/alter_db_owner.q.out Fri Jun 27 04:13:03 2014
@@ -6,6 +6,7 @@ PREHOOK: query: describe database db_alt
PREHOOK: type: DESCDATABASE
POSTHOOK: query: describe database db_alter_onr
POSTHOOK: type: DESCDATABASE
+db_alter_onr location/in/test hive_test_user USER
#### A masked pattern was here ####
PREHOOK: type: ALTERDATABASE_OWNER
PREHOOK: Output: database:db_alter_onr
@@ -16,6 +17,7 @@ PREHOOK: query: describe database db_alt
PREHOOK: type: DESCDATABASE
POSTHOOK: query: describe database db_alter_onr
POSTHOOK: type: DESCDATABASE
+db_alter_onr location/in/test user1 USER
#### A masked pattern was here ####
PREHOOK: type: ALTERDATABASE_OWNER
PREHOOK: Output: database:db_alter_onr
@@ -26,4 +28,4 @@ PREHOOK: query: describe database db_alt
PREHOOK: type: DESCDATABASE
POSTHOOK: query: describe database db_alter_onr
POSTHOOK: type: DESCDATABASE
-#### A masked pattern was here ####
+db_alter_onr location/in/test role1 ROLE
Modified: hive/trunk/ql/src/test/results/clientpositive/authorization_owner_actions_db.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/authorization_owner_actions_db.q.out?rev=1605945&r1=1605944&r2=1605945&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/authorization_owner_actions_db.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/authorization_owner_actions_db.q.out Fri Jun 27 04:13:03 2014
@@ -26,6 +26,7 @@ PREHOOK: query: desc database testdb
PREHOOK: type: DESCDATABASE
POSTHOOK: query: desc database testdb
POSTHOOK: type: DESCDATABASE
+testdb location/in/test testrole ROLE
#### A masked pattern was here ####
-- create table
use testdb
Modified: hive/trunk/ql/src/test/results/clientpositive/database_location.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/database_location.q.out?rev=1605945&r1=1605944&r2=1605945&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/database_location.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/database_location.q.out Fri Jun 27 04:13:03 2014
@@ -6,7 +6,7 @@ PREHOOK: query: DESCRIBE DATABASE EXTEND
PREHOOK: type: DESCDATABASE
POSTHOOK: query: DESCRIBE DATABASE EXTENDED db1
POSTHOOK: type: DESCDATABASE
-#### A masked pattern was here ####
+db1 location/in/test hive_test_user USER
PREHOOK: query: USE db1
PREHOOK: type: SWITCHDATABASE
POSTHOOK: query: USE db1
@@ -68,7 +68,7 @@ PREHOOK: query: DESCRIBE DATABASE EXTEND
PREHOOK: type: DESCDATABASE
POSTHOOK: query: DESCRIBE DATABASE EXTENDED db2
POSTHOOK: type: DESCDATABASE
-#### A masked pattern was here ####
+db2 database 2 location/in/test hive_test_user USER
PREHOOK: query: USE db2
PREHOOK: type: SWITCHDATABASE
POSTHOOK: query: USE db2
Modified: hive/trunk/ql/src/test/results/clientpositive/database_properties.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/database_properties.q.out?rev=1605945&r1=1605944&r2=1605945&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/database_properties.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/database_properties.q.out Fri Jun 27 04:13:03 2014
@@ -22,7 +22,7 @@ PREHOOK: query: describe database db2
PREHOOK: type: DESCDATABASE
POSTHOOK: query: describe database db2
POSTHOOK: type: DESCDATABASE
-#### A masked pattern was here ####
+db2 location/in/test hive_test_user USER
PREHOOK: query: describe database extended db2
PREHOOK: type: DESCDATABASE
POSTHOOK: query: describe database extended db2
Added: hive/trunk/ql/src/test/results/clientpositive/describe_database.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/describe_database.q.out?rev=1605945&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/describe_database.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/describe_database.q.out Fri Jun 27 04:13:03 2014
@@ -0,0 +1,17 @@
+PREHOOK: query: create database test_db with dbproperties ('key1' = 'value1', 'key2' = 'value2')
+PREHOOK: type: CREATEDATABASE
+POSTHOOK: query: create database test_db with dbproperties ('key1' = 'value1', 'key2' = 'value2')
+POSTHOOK: type: CREATEDATABASE
+PREHOOK: query: desc database extended test_db
+PREHOOK: type: DESCDATABASE
+POSTHOOK: query: desc database extended test_db
+POSTHOOK: type: DESCDATABASE
+test_db location/in/test hive_test_user USER {key2=value2, key1=value1}
+PREHOOK: query: drop database test_db
+PREHOOK: type: DROPDATABASE
+PREHOOK: Input: database:test_db
+PREHOOK: Output: database:test_db
+POSTHOOK: query: drop database test_db
+POSTHOOK: type: DROPDATABASE
+POSTHOOK: Input: database:test_db
+POSTHOOK: Output: database:test_db