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 tr...@apache.org on 2012/12/13 20:15:10 UTC

svn commit: r1421483 - in /incubator/hcatalog/branches/branch-0.4: ./ webhcat/java-client/src/main/java/org/apache/hcatalog/api/ webhcat/java-client/src/test/java/org/apache/hcatalog/api/

Author: travis
Date: Thu Dec 13 20:15:08 2012
New Revision: 1421483

URL: http://svn.apache.org/viewvc?rev=1421483&view=rev
Log:
HCATALOG-566 HCatTable doesn't report partition columns correctly.

Modified:
    incubator/hcatalog/branches/branch-0.4/CHANGES.txt
    incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java
    incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java
    incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java

Modified: incubator/hcatalog/branches/branch-0.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/CHANGES.txt?rev=1421483&r1=1421482&r2=1421483&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/CHANGES.txt (original)
+++ incubator/hcatalog/branches/branch-0.4/CHANGES.txt Thu Dec 13 20:15:08 2012
@@ -71,6 +71,8 @@ Trunk (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-566 HCatTable doesn't report partition columns correctly. (mithun via traviscrawford)
+
   HCAT-562 HCatClient should allow for a table's message-topic-name to be queried for. (mithunr via avandana)
 
   HCAT-561 HCatClient should differentiate between "partition not available" and other generic errors. (mithun via avandana)

Modified: incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java?rev=1421483&r1=1421482&r2=1421483&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java (original)
+++ incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java Thu Dec 13 20:15:08 2012
@@ -371,7 +371,7 @@ public class HCatCreateTableDesc{
            * @param partCols the partition cols
            * @return the builder
            */
-          public Builder partCols(ArrayList<HCatFieldSchema> partCols) {
+          public Builder partCols(List<HCatFieldSchema> partCols) {
               this.partCols = partCols;
               return this;
           }
@@ -383,7 +383,7 @@ public class HCatCreateTableDesc{
            * @param bucketCols the bucket cols
            * @return the builder
            */
-          public Builder bucketCols(ArrayList<String> bucketCols, int buckets) {
+          public Builder bucketCols(List<String> bucketCols, int buckets) {
             this.bucketCols = bucketCols;
             this.numBuckets = buckets;
             return this;

Modified: incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java?rev=1421483&r1=1421482&r2=1421483&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java (original)
+++ incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java Thu Dec 13 20:15:08 2012
@@ -58,7 +58,7 @@ public class HCatTable {
         }
         partCols = new ArrayList<HCatFieldSchema>();
         for (FieldSchema colFS : hiveTable.getPartitionKeys()) {
-            cols.add(HCatSchemaUtils.getHCatFieldSchema(colFS));
+            partCols.add(HCatSchemaUtils.getHCatFieldSchema(colFS));
         }
         bucketCols = hiveTable.getSd().getBucketCols();
         sortCols = hiveTable.getSd().getSortCols();

Modified: incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java?rev=1421483&r1=1421482&r2=1421483&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java (original)
+++ incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java Thu Dec 13 20:15:08 2012
@@ -203,7 +203,7 @@ public class TestHCatClient {
 
         Map<String, String> thirdPtn = new HashMap<String, String>();
         thirdPtn.put("dt", "04/13/2012");
-        thirdPtn.put("country", "argetina");
+        thirdPtn.put("country", "argentina");
         HCatAddPartitionDesc addPtn3 = HCatAddPartitionDesc.create(dbName,
                 tableName, null, thirdPtn).build();
         client.addPartition(addPtn3);
@@ -221,7 +221,7 @@ public class TestHCatClient {
         assertTrue(ptnList.size() == 2);
 
         List<HCatPartition> ptnListTwo = client.listPartitionsByFilter(dbName,
-                tableName, "country = \"argetina\"");
+                tableName, "country = \"argentina\"");
         assertTrue(ptnListTwo.size() == 1);
 
         client.markPartitionForEvent(dbName, tableName, thirdPtn,
@@ -502,4 +502,35 @@ public class TestHCatClient {
         }
     }
 
+    @Test
+    public void testPartitionSchema() throws Exception {
+        try {
+            HCatClient client = HCatClient.create(new Configuration(hcatConf));
+            final String dbName = "myDb";
+            final String tableName = "myTable";
+
+            client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);
+
+            client.createDatabase(HCatCreateDBDesc.create(dbName).build());
+            List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""),
+                    new HCatFieldSchema("bar", Type.STRING, ""));
+
+            List<HCatFieldSchema> partitionSchema = Arrays.asList(new HCatFieldSchema("dt", Type.STRING, ""),
+                    new HCatFieldSchema("grid", Type.STRING, ""));
+
+            client.createTable(HCatCreateTableDesc.create(dbName, tableName, columnSchema).partCols(partitionSchema).build());
+
+            HCatTable table = client.getTable(dbName, tableName);
+            List<HCatFieldSchema> partitionColumns = table.getPartCols();
+
+            assertArrayEquals("Didn't get expected partition-schema back from the HCatTable.",
+                    partitionSchema.toArray(), partitionColumns.toArray());
+            client.dropDatabase(dbName, false, HCatClient.DropDBMode.CASCADE);
+        }
+        catch (Exception unexpected) {
+            LOG.error("Unexpected exception!", unexpected);
+            assertTrue("Unexpected exception! " + unexpected.getMessage(), false);
+        }
+    }
+
 }