Author: hashutosh
Date: Sat Nov 19 20:28:11 2011
New Revision: 1204069

URL: http://svn.apache.org/viewvc?rev=1204069&view=rev
Log:
HCATALOG-125: HCat doesn't support hive's describe database DDL

Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    
incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/SemanticAnalysis/HCatSemanticAnalyzer.java
    
incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1204069&r1=1204068&r2=1204069&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Sat Nov 19 20:28:11 2011
@@ -79,6 +79,8 @@ Trunk (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-125. HCat doesn't support hive's describe database DDL (hashutosh)
+
   HCAT-159. Build broken by recent Hive changes that move around jar files  
part-2 (thw via hashutosh)
 
   HCAT-159. Build broken by recent Hive changes that move around jar files 
(gates)

Modified: 
incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/SemanticAnalysis/HCatSemanticAnalyzer.java
URL: 
http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/SemanticAnalysis/HCatSemanticAnalyzer.java?rev=1204069&r1=1204068&r2=1204069&view=diff
==============================================================================
--- 
incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/SemanticAnalysis/HCatSemanticAnalyzer.java
 (original)
+++ 
incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/SemanticAnalysis/HCatSemanticAnalyzer.java
 Sat Nov 19 20:28:11 2011
@@ -63,13 +63,12 @@ public class HCatSemanticAnalyzer extend
       hook = new CreateDatabaseHook();
       return hook.preAnalyze(context, ast);
 
-    // DML commands used in HCat where we use the same implementation as 
default Hive.
+    // HCat will allow these operations to be performed since they are DDL 
statements.
     case HiveParser.TOK_SHOWDATABASES:
     case HiveParser.TOK_DROPDATABASE:
     case HiveParser.TOK_SWITCHDATABASE:
-      return ast;
+    case HiveParser.TOK_DESCDATABASE:
 
-    // HCat will allow these operations to be performed since they are DDL 
statements.
     case HiveParser.TOK_DROPTABLE:
     case HiveParser.TOK_DESCTABLE:
     case HiveParser.TOK_ALTERTABLE_ADDCOLS:
@@ -138,6 +137,7 @@ public class HCatSemanticAnalyzer extend
         
authorize(BaseSemanticAnalyzer.unescapeIdentifier(((ASTNode)ast.getChild(0)).getChild(0).getText()),
 context, FsAction.WRITE, false);
         break;
 
+      case HiveParser.TOK_DESCDATABASE:
       case HiveParser.TOK_SWITCHDATABASE:
         
authorize(BaseSemanticAnalyzer.getUnescapedName((ASTNode)ast.getChild(0)), 
context, FsAction.READ, true);
         break;

Modified: 
incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java
URL: 
http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java?rev=1204069&r1=1204068&r2=1204069&view=diff
==============================================================================
--- 
incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java
 (original)
+++ 
incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java
 Sat Nov 19 20:28:11 2011
@@ -77,6 +77,17 @@ public class TestSemanticAnalysis extend
   String query;
   private final String tblName = "junit_sem_analysis";
 
+  public void testDescDB() throws CommandNeedRetryException, IOException {
+       hcatDriver.run("drop database mydb cascade");
+       assertEquals(0, hcatDriver.run("create database 
mydb").getResponseCode());
+       CommandProcessorResponse resp = hcatDriver.run("describe database 
mydb");
+       assertEquals(0, resp.getResponseCode());
+       ArrayList<String> result = new ArrayList<String>();
+       hcatDriver.getResults(result);
+       assertTrue(result.get(0).contains("mydb.db"));
+       hcatDriver.run("drop database mydb cascade");
+  }
+  
   public void testCreateTblWithLowerCasePartNames() throws 
CommandNeedRetryException, MetaException, TException, NoSuchObjectException{
     hiveDriver.run("drop table junit_sem_analysis");
     CommandProcessorResponse resp = hiveDriver.run("create table 
junit_sem_analysis (a int) partitioned by (B string) stored as TEXTFILE");


Reply via email to