You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hcatalog-commits@incubator.apache.org by ga...@apache.org on 2012/08/23 01:25:08 UTC

svn commit: r1376340 - in /incubator/hcatalog/trunk: CHANGES.txt src/java/org/apache/hcatalog/cli/SemanticAnalysis/HCatSemanticAnalyzer.java

Author: gates
Date: Thu Aug 23 01:25:08 2012
New Revision: 1376340

URL: http://svn.apache.org/viewvc?rev=1376340&view=rev
Log:
HCATALOG-471 Test HCat_ShowDes_1[1-3] fails

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

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1376340&r1=1376339&r2=1376340&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Thu Aug 23 01:25:08 2012
@@ -83,6 +83,8 @@ Trunk (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-471 Test HCat_ShowDes_1[1-3] fails (vikram.dixit via gates)
+
   HCAT-470 Update HCat version numbers in Templeton doc set (lefty via gates)
 
   HCAT-472 HCatalog should use Deserializer in the read path instead of SerDe (traviscrawford)

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=1376340&r1=1376339&r2=1376340&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 Thu Aug 23 01:25:08 2012
@@ -243,6 +243,19 @@ public class HCatSemanticAnalyzer extend
     }
   }
 
+  private String extractTableName (String compoundName) {
+    /* 
+     * the table name can potentially be a dot-format one with column names
+     * specified as part of the table name. e.g. a.b.c where b is a column in
+     * a and c is a field of the object/column b etc. For authorization 
+     * purposes, we should use only the first part of the dotted name format.
+     *
+     */
+
+   String [] words = compoundName.split("\\.");
+   return words[0];
+  }
+
   @Override
   protected void authorizeDDLWork(HiveSemanticAnalyzerHookContext cntxt, Hive hive, DDLWork work)
       throws HiveException {
@@ -344,14 +357,19 @@ public class HCatSemanticAnalyzer extend
       //other alter operations are already supported by Hive
     }
 
+    // we should be careful when authorizing table based on just the 
+    // table name. If columns have separate authorization domain, it 
+    // must be honored
     DescTableDesc descTable = work.getDescTblDesc();
     if (descTable != null) {
-      authorizeTable(cntxt.getHive(), descTable.getTableName(), Privilege.SELECT);
+      String tableName = extractTableName(descTable.getTableName());
+      authorizeTable(cntxt.getHive(), tableName, Privilege.SELECT);
     }
 
     ShowPartitionsDesc showParts = work.getShowPartsDesc();
     if (showParts != null) {
-      authorizeTable(cntxt.getHive(), showParts.getTabName(), Privilege.SELECT);
+      String tableName = extractTableName(showParts.getTabName());
+      authorizeTable(cntxt.getHive(), tableName, Privilege.SELECT);
     }
   }
 }