incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tra...@apache.org
Subject svn commit: r1421445 - in /incubator/hcatalog/trunk: ./ webhcat/java-client/src/main/java/org/apache/hcatalog/api/ webhcat/java-client/src/test/java/org/apache/hcatalog/api/
Date Thu, 13 Dec 2012 19:42:39 GMT
Author: travis
Date: Thu Dec 13 19:42:38 2012
New Revision: 1421445

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

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

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1421445&r1=1421444&r2=1421445&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Thu Dec 13 19:42:38 2012
@@ -151,6 +151,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.(mithunr via avandana)

Modified: incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java?rev=1421445&r1=1421444&r2=1421445&view=diff
==============================================================================
--- incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java
(original)
+++ incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatCreateTableDesc.java
Thu Dec 13 19:42:38 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/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java?rev=1421445&r1=1421444&r2=1421445&view=diff
==============================================================================
--- incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java
(original)
+++ incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatTable.java
Thu Dec 13 19:42:38 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/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java?rev=1421445&r1=1421444&r2=1421445&view=diff
==============================================================================
--- incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java
(original)
+++ incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java
Thu Dec 13 19:42:38 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,
@@ -501,4 +501,35 @@ public class TestHCatClient {
             assertTrue("Unexpected exception:" + exception.getMessage(), false);
         }
     }
+
+    @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);
+        }
+    }
 }



Mime
View raw message