diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 565549a..92caeab 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -3251,6 +3251,12 @@ public boolean equals(Object obj) { part.getTableName(), part.toString()); throw new MetaException(errorMsg); } + if (part.getValues() == null || part.getValues().isEmpty()) { + throw new MetaException("The partition values cannot be null or empty."); + } + if (part.getValues().contains(null)) { + throw new MetaException("Partition value cannot be null."); + } boolean shouldAdd = startAddPartition(ms, part, ifNotExists); if (!shouldAdd) { @@ -3411,7 +3417,10 @@ public AddPartitionsResult add_partitions_req(AddPartitionsRequest request) public int add_partitions(final List parts) throws MetaException, InvalidObjectException, AlreadyExistsException { startFunction("add_partition"); - if (parts.size() == 0) { + if (parts == null) { + throw new MetaException("Partition list cannot be null."); + } + if (parts.isEmpty()) { return 0; } @@ -3472,6 +3481,9 @@ private int add_partitions_pspec_core(RawStore ms, String catName, String dbName boolean ifNotExists) throws TException { boolean success = false; + if (dbName == null || tblName == null) { + throw new MetaException("The database and table name cannot be null."); + } // Ensures that the list doesn't have dups, and keeps track of directories we have created. final Map addedPartitions = new ConcurrentHashMap<>(); PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partSpecs); @@ -3497,12 +3509,18 @@ private int add_partitions_pspec_core(RawStore ms, String catName, String dbName // will be created if the list contains an invalid partition. final Partition part = partitionIterator.getCurrent(); + if (part.getDbName() == null || part.getTableName() == null) { + throw new MetaException("The database and table name must be set in the partition."); + } if (!part.getTableName().equalsIgnoreCase(tblName) || !part.getDbName().equalsIgnoreCase(dbName)) { String errorMsg = String.format( "Partition does not belong to target table %s.%s. It belongs to the table %s.%s : %s", dbName, tblName, part.getDbName(), part.getTableName(), part.toString()); throw new MetaException(errorMsg); } + if (part.getValues() == null || part.getValues().isEmpty()) { + throw new MetaException("The partition values cannot be null or empty."); + } boolean shouldAdd = startAddPartition(ms, part, ifNotExists); if (!shouldAdd) { @@ -3734,6 +3752,9 @@ private Partition add_partition_core(final RawStore ms, firePreEvent(new PreAddPartitionEvent(tbl, part, this)); + if (part.getValues() == null || part.getValues().isEmpty()) { + throw new MetaException("The partition values cannot be null or empty."); + } boolean shouldAdd = startAddPartition(ms, part, false); assert shouldAdd; // start would throw if it already existed here boolean madeDir = createLocationForAddedPartition(tbl, part); @@ -3790,6 +3811,9 @@ public Partition add_partition_with_environment_context( final Partition part, EnvironmentContext envContext) throws InvalidObjectException, AlreadyExistsException, MetaException { + if (part == null) { + throw new MetaException("Partition cannot be null."); + } startTableFunction("add_partition", part.getCatName(), part.getDbName(), part.getTableName()); Partition ret = null; diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 9a43b2c..6b3e71a 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -650,7 +650,7 @@ public Partition add_partition(Partition new_part) throws TException { public Partition add_partition(Partition new_part, EnvironmentContext envContext) throws TException { - if (!new_part.isSetCatName()) new_part.setCatName(getDefaultCatalog(conf)); + if (new_part != null && !new_part.isSetCatName()) new_part.setCatName(getDefaultCatalog(conf)); Partition p = client.add_partition_with_environment_context(new_part, envContext); return deepCopy(p); } @@ -665,6 +665,9 @@ public Partition add_partition(Partition new_part, EnvironmentContext envContext */ @Override public int add_partitions(List new_parts) throws TException { + if (new_parts == null || new_parts.contains(null)) { + throw new MetaException("Partitions cannot be null."); + } if (new_parts != null && !new_parts.isEmpty() && !new_parts.get(0).isSetCatName()) { final String defaultCat = getDefaultCatalog(conf); new_parts.forEach(p -> p.setCatName(defaultCat)); @@ -675,6 +678,9 @@ public int add_partitions(List new_parts) throws TException { @Override public List add_partitions( List parts, boolean ifNotExists, boolean needResults) throws TException { + if (parts == null || parts.contains(null)) { + throw new MetaException("Partitions cannot be null."); + } if (parts.isEmpty()) { return needResults ? new ArrayList<>() : null; } @@ -689,6 +695,9 @@ public int add_partitions(List new_parts) throws TException { @Override public int add_partitions_pspec(PartitionSpecProxy partitionSpec) throws TException { + if (partitionSpec == null) { + throw new MetaException("PartitionSpec cannot be null."); + } if (partitionSpec.getCatName() == null) partitionSpec.setCatName(getDefaultCatalog(conf)); return client.add_partitions_pspec(partitionSpec.toPartitionSpec()); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java index 92813b9..91d790a 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java @@ -40,7 +40,7 @@ private List partitionSpecProxies; private int size = 0; - protected CompositePartitionSpecProxy(List partitionSpecs) { + protected CompositePartitionSpecProxy(List partitionSpecs) throws MetaException { this.partitionSpecs = partitionSpecs; if (partitionSpecs.isEmpty()) { catName = null; @@ -63,13 +63,13 @@ protected CompositePartitionSpecProxy(List partitionSpecs) { } @Deprecated - protected CompositePartitionSpecProxy(String dbName, String tableName, List partitionSpecs) { + protected CompositePartitionSpecProxy(String dbName, String tableName, List partitionSpecs) throws MetaException { this(DEFAULT_CATALOG_NAME, dbName, tableName, partitionSpecs); } protected CompositePartitionSpecProxy(String catName, String dbName, String tableName, - List partitionSpecs) { + List partitionSpecs) throws MetaException { this.catName = catName; this.dbName = dbName; this.tableName = tableName; diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java index 6bd29d0..585b8fd 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java @@ -20,6 +20,7 @@ import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec; import org.apache.hadoop.hive.metastore.api.PartitionSpec; import java.util.Arrays; @@ -33,9 +34,24 @@ private PartitionSpec partitionSpec; - protected PartitionListComposingSpecProxy(PartitionSpec partitionSpec) { + protected PartitionListComposingSpecProxy(PartitionSpec partitionSpec) throws MetaException { assert partitionSpec.isSetPartitionList() : "Partition-list should have been set."; + PartitionListComposingSpec partitionList = partitionSpec.getPartitionList(); + if (partitionList == null || partitionList.getPartitions() == null) { + throw new MetaException("The partition list cannot be null."); + } + for (Partition partition : partitionList.getPartitions()) { + if (partition == null) { + throw new MetaException("Partition cannot be null."); + } + if (partition.getValues() == null || partition.getValues().isEmpty()) { + throw new MetaException("The partition value list cannot be null or empty."); + } + if (partition.getValues().contains(null)) { + throw new MetaException("Partition value cannot be null."); + } + } this.partitionSpec = partitionSpec; } @@ -102,6 +118,10 @@ public void setRootLocation(String newRootPath) throws MetaException { throw new MetaException("No common root-path. Can't replace root-path!"); } + if (newRootPath == null) { + throw new MetaException("Root path cannot be null."); + } + for (Partition partition : partitionSpec.getPartitionList().getPartitions()) { String location = partition.getSd().getLocation(); if (location.startsWith(oldRootPath)) { diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java index ff2dea1..1866446 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java @@ -100,8 +100,9 @@ * Factory method. Construct PartitionSpecProxy from raw PartitionSpec. * @param partSpec Raw PartitionSpec from the Thrift API. * @return PartitionSpecProxy instance. + * @throws MetaException */ - public static PartitionSpecProxy get(PartitionSpec partSpec) { + public static PartitionSpecProxy get(PartitionSpec partSpec) throws MetaException { if (partSpec == null) { return null; @@ -123,8 +124,9 @@ public static PartitionSpecProxy get(PartitionSpec partSpec) { * Factory method to construct CompositePartitionSpecProxy. * @param partitionSpecs List of raw PartitionSpecs. * @return A CompositePartitionSpecProxy instance. + * @throws MetaException */ - public static PartitionSpecProxy get(List partitionSpecs) { + public static PartitionSpecProxy get(List partitionSpecs) throws MetaException { return new CompositePartitionSpecProxy(partitionSpecs); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java index 61e00ea..5b46206 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java @@ -38,8 +38,11 @@ private PartitionSpec partitionSpec; - public PartitionSpecWithSharedSDProxy(PartitionSpec partitionSpec) { + public PartitionSpecWithSharedSDProxy(PartitionSpec partitionSpec) throws MetaException { assert partitionSpec.isSetSharedSDPartitionSpec(); + if (partitionSpec.getSharedSDPartitionSpec().getSd() == null) { + throw new MetaException("The shared storage descriptor must be set."); + } this.partitionSpec = partitionSpec; } diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java index f8497c7..88064d9 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java @@ -46,7 +46,6 @@ import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TException; -import org.apache.thrift.transport.TTransportException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -512,7 +511,7 @@ public void testAddPartitionTooManyValues() throws Exception { @Test(expected = MetaException.class) public void testAddPartitionNoPartColOnTable() throws Exception { - Table origTable = new TableBuilder() + new TableBuilder() .setDbName(DB_NAME) .setTableName(TABLE_NAME) .addCol("test_id", "int", "test col id") @@ -575,27 +574,19 @@ public void testAddPartitionMorePartColInTable() throws Exception { client.add_partition(partition); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionNullPartition() throws Exception { - try { - client.add_partition(null); - Assert.fail("Exception should have been thrown."); - } catch (TTransportException | NullPointerException e) { - // TODO: NPE should not be thrown. - } + + client.add_partition(null); } - @Test - public void testAddPartitionNullValue() throws Exception { + @Test(expected = MetaException.class) + public void testAddPartitionNullValues() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, null); - try { - client.add_partition(partition); - } catch (NullPointerException e) { - // TODO: This works different in remote and embedded mode. - // In embedded mode, no exception happens. - } + partition.setValues(null); + client.add_partition(partition); } @Test @@ -698,14 +689,10 @@ public void testAddPartitionsWithDefaultAttributes() throws Exception { verifyPartitionAttributesDefaultValues(part, table.getSd().getLocation()); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionsNullList() throws Exception { - try { - client.add_partitions(null); - Assert.fail("Exception should have been thrown."); - } catch (TTransportException | NullPointerException e) { - // TODO: NPE should not be thrown - } + + client.add_partitions(null); } @Test @@ -1159,31 +1146,23 @@ public void testAddPartitionsMorePartColInTable() throws Exception { client.add_partitions(partitions); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionsNullPartition() throws Exception { - try { - List partitions = new ArrayList<>(); - partitions.add(null); - client.add_partitions(partitions); - Assert.fail("Exception should have been thrown."); - } catch (TTransportException | NullPointerException e) { - // TODO: NPE should not be thrown - } + + List partitions = new ArrayList<>(); + partitions.add(null); + client.add_partitions(partitions); } - @Test - public void testAddPartitionsNullValue() throws Exception { + @Test(expected = MetaException.class) + public void testAddPartitionsNullValues() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, null); + partition.setValues(null); List partitions = new ArrayList<>(); partitions.add(partition); - try { - client.add_partitions(partitions); - } catch (NullPointerException e) { - // TODO: This works different in remote and embedded mode. - // In embedded mode, no exception happens. - } + client.add_partitions(partitions); } @Test @@ -1313,9 +1292,9 @@ public void testAddPartsMultipleValues() throws Exception { verifyPartition(table, "year=2016/month=march", Lists.newArrayList("2016", "march"), 3); } - @Test(expected = NullPointerException.class) + @Test(expected = MetaException.class) public void testAddPartsNullList() throws Exception { - // TODO: NPE should not be thrown + client.add_partitions(null, false, false); } @@ -1429,9 +1408,9 @@ public void testAddPartsAlreadyExistsIfExistsTrue() throws Exception { Assert.assertTrue(partitionNames.contains("year=2017")); } - @Test(expected = NullPointerException.class) + @Test(expected = MetaException.class) public void testAddPartsNullPartition() throws Exception { - // TODO: NPE should not be thrown + List partitions = new ArrayList<>(); partitions.add(null); client.add_partitions(partitions, false, false); @@ -1452,7 +1431,7 @@ private Table createTable(String dbName, String tableName, String location) thro private Table createTable(String dbName, String tableName, List partCols, String location) throws Exception { - Table table = new TableBuilder() + new TableBuilder() .setDbName(dbName) .setTableName(tableName) .addCol("test_id", "int", "test col id") diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java index fc0c60f..debcd0e 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; -import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; import org.apache.hadoop.hive.metastore.api.MetaException; @@ -45,7 +44,6 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy; import org.apache.thrift.TException; -import org.apache.thrift.transport.TTransportException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -170,10 +168,9 @@ public void testAddPartitionSpecsMultipleValues() throws Exception { // TODO add tests for partitions in other catalogs - @Test(expected = NullPointerException.class) + @Test(expected = MetaException.class) public void testAddPartitionSpecNullSpec() throws Exception { - // TODO: NPE should not be thrown. client.add_partitions_pspec(null); } @@ -186,51 +183,36 @@ public void testAddPartitionSpecEmptyPartList() throws Exception { client.add_partitions_pspec(partitionSpec); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionSpecNullPartList() throws Exception { createTable(); List partitions = null; PartitionSpecProxy partitionSpec = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions); - try { - client.add_partitions_pspec(partitionSpec); - Assert.fail("Exception should have been thrown."); - } catch (NullPointerException | TTransportException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpec); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionSpecNoDB() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(null, TABLE_NAME, null, Lists.newArrayList(partition)); - try { - client.add_partitions_pspec(partitionSpecProxy); - Assert.fail("Exception should have been thrown."); - } catch (NullPointerException | TTransportException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpecProxy); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionSpecNoTable() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, null, null, Lists.newArrayList(partition)); - try { - client.add_partitions_pspec(partitionSpecProxy); - Assert.fail("Exception should have been thrown."); - } catch (NullPointerException | TTransportException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpecProxy); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionSpecNoDBAndTableInPartition() throws Exception { createTable(); @@ -239,12 +221,7 @@ public void testAddPartitionSpecNoDBAndTableInPartition() throws Exception { partition.setTableName(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); - try { - client.add_partitions_pspec(partitionSpecProxy); - Assert.fail("Exception should have been thrown."); - } catch (NullPointerException | TTransportException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpecProxy); } @Test @@ -346,7 +323,7 @@ public void testAddPartitionSpecDiffDBName() throws Exception { } } - @Test + @Test(expected = MetaException.class) public void testAddPartitionSpecNullPart() throws Exception { createTable(); @@ -357,11 +334,7 @@ public void testAddPartitionSpecNullPart() throws Exception { partitions.add(partition2); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions); - try { - client.add_partitions_pspec(partitionSpecProxy); - } catch (NullPointerException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpecProxy); } @Test @@ -457,7 +430,7 @@ public void testAddPartitionSpecChangeRootPathFromNull() throws Exception { client.add_partitions_pspec(partitionSpecProxy); } - @Test(expected = NullPointerException.class) + @Test(expected = MetaException.class) public void testAddPartitionSpecChangeRootPathToNull() throws Exception { Table table = createTable(); @@ -467,7 +440,6 @@ public void testAddPartitionSpecChangeRootPathToNull() throws Exception { buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath, Lists.newArrayList(partition)); partitionSpecProxy.setRootLocation(null); client.add_partitions_pspec(partitionSpecProxy); - // TODO: NPE should not be thrown. } @Test(expected = MetaException.class) @@ -596,7 +568,7 @@ public void testAddPartitionSpecNullSd() throws Exception { client.add_partitions_pspec(partitionSpecProxy); } - @Test + @Test(expected = MetaException.class) public void testAddPartitionSpecWithSharedSDNullSd() throws Exception { createTable(); @@ -604,12 +576,7 @@ public void testAddPartitionSpecWithSharedSDNullSd() throws Exception { StorageDescriptor sd = null; PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), sd); - try { - client.add_partitions_pspec(partitionSpecProxy); - Assert.fail("Exception should have been thrown."); - } catch (NullPointerException | TTransportException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpecProxy); } @Test(expected = MetaException.class) @@ -734,7 +701,7 @@ public void testAddPartitionsForViewNullPartSd() throws Exception { Assert.assertNull(part.getSd()); } - @Test + @Test(expected=MetaException.class) public void testAddPartitionSpecWithSharedSDNoValue() throws Exception { Table table = createTable(); @@ -743,12 +710,7 @@ public void testAddPartitionSpecWithSharedSDNoValue() throws Exception { String location = table.getSd().getLocation() + "/nullValueTest/"; PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location)); - try { - client.add_partitions_pspec(partitionSpecProxy); - Assert.fail("Exception should have been thrown."); - } catch (NullPointerException | TTransportException e) { - // TODO: NPE should not be thrown. - } + client.add_partitions_pspec(partitionSpecProxy); } @Test(expected=MetaException.class) @@ -767,18 +729,15 @@ public void testAddPartitionSpecNoValue() throws Exception { client.add_partitions_pspec(partitionSpecProxy); } - @Test - public void testAddPartitionSpecNullValue() throws Exception { + @Test(expected = MetaException.class) + public void testAddPartitionSpecNullValues() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, null); + partition.setValues(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); - try { - client.add_partitions_pspec(partitionSpecProxy); - } catch (NullPointerException e) { - // TODO: NPE should not be thrown - } + client.add_partitions_pspec(partitionSpecProxy); } @Test @@ -938,7 +897,7 @@ public void testAddPartitionSpecMoreThanThreadCountsOneFails() throws Exception // Helper methods private void createDB(String dbName) throws TException { - Database db = new DatabaseBuilder().setName(dbName).create(client, metaStore.getConf()); + new DatabaseBuilder().setName(dbName).create(client, metaStore.getConf()); } private Table createTable() throws Exception { @@ -948,7 +907,7 @@ private Table createTable() throws Exception { private Table createTable(String dbName, String tableName, List partCols, String location) throws Exception { - Table table = new TableBuilder() + new TableBuilder() .setDbName(dbName) .setTableName(tableName) .addCol("test_id", "int", "test col id") @@ -1073,7 +1032,7 @@ private PartitionWithoutSD buildPartitionWithoutSD(List values, int inde } private PartitionSpecProxy buildPartitionSpec(String dbName, String tableName, String rootPath, - List partitions) { + List partitions) throws MetaException { PartitionSpec partitionSpec = new PartitionSpec(); partitionSpec.setDbName(dbName); @@ -1104,7 +1063,7 @@ private StorageDescriptor buildSD(String location) { } private PartitionSpecProxy buildPartitionSpecWithSharedSD(List partitions, - StorageDescriptor sd) { + StorageDescriptor sd) throws MetaException { PartitionSpec partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME);