diff --git ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java index b71ef5a725..957ebb1272 100644 --- ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -50,19 +51,22 @@ import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj; import org.apache.hadoop.hive.metastore.api.EnvironmentContext; import org.apache.hadoop.hive.metastore.api.FieldSchema; -import org.apache.hadoop.hive.metastore.api.HiveObjectRef; -import org.apache.hadoop.hive.metastore.api.HiveObjectType; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; import org.apache.hadoop.hive.metastore.api.InvalidOperationException; +import org.apache.hadoop.hive.metastore.api.HiveObjectRef; +import org.apache.hadoop.hive.metastore.api.HiveObjectType; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; 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 org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet; import org.apache.hadoop.hive.metastore.api.SetPartitionsStatsRequest; import org.apache.hadoop.hive.metastore.api.TableMeta; import org.apache.hadoop.hive.metastore.api.UnknownDBException; import org.apache.hadoop.hive.metastore.api.UnknownTableException; +import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy; import org.apache.hadoop.hive.ql.parse.SemanticAnalyzer; import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils; import org.apache.hadoop.hive.metastore.utils.SecurityUtils; @@ -960,8 +964,8 @@ private int addPartitions(List partitions) throws AlreadyExistsExcept return partitions; } - private List getPartitions(List partialPartVals) throws MetaException { - return pTree.getPartitions(partialPartVals); + private List getPartitionsByPartitionVals(List partialPartVals) throws MetaException { + return pTree.getPartitionsByPartitionVals(partialPartVals); } private Partition getPartitionWithAuthInfo(List partionVals, String userName, List groupNames) @@ -973,13 +977,40 @@ private Partition getPartitionWithAuthInfo(List partionVals, String user return checkPrivilegesForPartition(partition, userName, groupNames) ? partition : null; } + private List listPartitions() throws MetaException { + return pTree.listPartitions(); + } + + private List listPartitionsWithAuthInfo(String userName, List groupNames) throws MetaException { + List partitions = listPartitions(); + List result = new ArrayList<>(); + partitions.forEach(p -> { + if (checkPrivilegesForPartition(p, userName, groupNames)) { + result.add(p); + } + }); + return result; + } + + private List listPartitionsByPartitionValsWithAuthInfo(List partialVals, String userName, + List groupNames) throws MetaException { + List partitions = pTree.getPartitionsByPartitionVals(partialVals); + List result = new ArrayList<>(); + partitions.forEach(p -> { + if (checkPrivilegesForPartition(p, userName, groupNames)) { + result.add(p); + } + }); + return result; + } + private boolean checkPrivilegesForPartition(Partition partition, String userName, List groupNames) { if ((userName == null || userName.isEmpty()) && (groupNames == null || groupNames.isEmpty())) { return true; } PrincipalPrivilegeSet privileges = partition.getPrivileges(); if (privileges == null) { - return false; + return true; } if (privileges.isSetUserPrivileges()) { if (!privileges.getUserPrivileges().containsKey(userName)) { @@ -1004,7 +1035,7 @@ private boolean checkPrivilegesForPartition(Partition partition, String userName * via references. */ private static final class PartitionTree { - private final Map parts = new HashMap<>(); + private final Map parts = new LinkedHashMap<>(); private final org.apache.hadoop.hive.metastore.api.Table tTable; private PartitionTree(org.apache.hadoop.hive.metastore.api.Table t) { @@ -1053,18 +1084,29 @@ private int addPartitions(List partitions) * Missing values should be represented as "" (empty strings). May provide fewer values. * So if part cols are a,b,c, {"",2} is a valid list * {@link MetaStoreUtils#getPvals(List, Map)} - * */ - private List getPartitions(List partialPartVals) throws MetaException { + private List getPartitionsByPartitionVals(List partialPartVals) throws MetaException { + if (partialPartVals == null || partialPartVals.isEmpty()) { + throw new MetaException("Partition partial vals cannot be null or empty"); + } String partNameMatcher = MetaStoreUtils.makePartNameMatcher(tTable, partialPartVals, ".*"); List matchedPartitions = new ArrayList<>(); - for(String key : parts.keySet()) { - if(key.matches(partNameMatcher)) { + for (String key : parts.keySet()) { + if (key.matches(partNameMatcher)) { matchedPartitions.add(parts.get(key)); } } return matchedPartitions; } + + /** + * Get all the partitions. + * + * @return partitions list + */ + private List listPartitions() { + return new ArrayList<>(parts.values()); + } } } /** @@ -1084,10 +1126,6 @@ private int addPartitions(List partitions) return super.add_partition(partition); } TempTable tt = getPartitionedTempTable(table); - if(tt == null) { - throw new IllegalStateException("TempTable not found for " + - Warehouse.getQualifiedName(table)); - } tt.addPartition(deepCopy(partition)); return partition; } @@ -1112,10 +1150,6 @@ public int add_partitions(List partitions) throws TException { return super.add_partitions(partitions); } TempTable tt = getPartitionedTempTable(table); - if (tt == null) { - throw new IllegalStateException("TempTable not found for" + - table.getTableName()); - } return tt.addPartitions(deepCopyPartitions(partitions)); } @@ -1126,12 +1160,7 @@ public Partition getPartition(String catName, String dbName, String tblName, Str if (table == null) { return super.getPartition(catName, dbName, tblName, name); } - assertPartitioned(table); TempTable tt = getPartitionedTempTable(table); - if(tt == null) { - throw new IllegalStateException("TempTable not found for " + - getCatalogQualifiedTableName(table)); - } Partition partition = tt.getPartition(name); if (partition == null) { throw new NoSuchObjectException("Partition with name " + name + " for table " + tblName + " in database " + @@ -1148,12 +1177,7 @@ public Partition getPartition(String catName, String dbName, String tblName, if (table == null) { return super.getPartition(catName, dbName, tblName, partVals); } - assertPartitioned(table); TempTable tt = getPartitionedTempTable(table); - if(tt == null) { - throw new IllegalStateException("TempTable not found for " + - getCatalogQualifiedTableName(table)); - } Partition partition = tt.getPartition(partVals); if (partition == null) { throw new NoSuchObjectException("Partition with partition values " + @@ -1179,46 +1203,134 @@ public Partition getPartition(String catName, String dbName, String tblName, groupNames); } TempTable tt = getPartitionedTempTable(table); - if(tt == null) { - throw new IllegalStateException("TempTable not found for " + - Warehouse.getQualifiedName(table)); + List parts = tt.listPartitionsByPartitionValsWithAuthInfo(partialPvals, userName, groupNames); + if (parts.isEmpty()) { + throw new NoSuchObjectException("Partition with partition values " + + (partialPvals != null ? Arrays.toString(partialPvals.toArray()) : "null") + + " for table " + tableName + " in database " + dbName + " is not found"); } - List parts = tt.getPartitions(partialPvals); List matchedParts = new ArrayList<>(); - for(int i = 0; i < (maxParts <= 0 ? parts.size() : maxParts); i++) { + for(int i = 0; i < ((maxParts < 0 || maxParts > parts.size()) ? parts.size() : maxParts); i++) { matchedParts.add(deepCopy(parts.get(i))); } return matchedParts; } - /** - * Returns a list of partition names, i.e. "p=1/q=2" type strings. The values (RHS of =) are - * escaped. - */ @Override - public List listPartitionNames(String dbName, String tableName, - short maxParts) throws TException { + public List listPartitionsWithAuthInfo(String catName, String dbName, String tableName, + int maxParts, String userName, List groupNames) + throws TException { org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tableName); if (table == null) { - //(assume) not a temp table - Try underlying client - return super.listPartitionNames(dbName, tableName, maxParts); + return super.listPartitionsWithAuthInfo(catName, dbName, tableName, maxParts, userName, groupNames); } TempTable tt = getPartitionedTempTable(table); - if(tt == null) { - throw new IllegalStateException("TempTable not found for " + - Warehouse.getQualifiedName(table)); + List partitions = tt.listPartitionsWithAuthInfo(userName, groupNames); + if (partitions.isEmpty()) { + throw new NoSuchObjectException( + "Partition for table " + tableName + " in database " + dbName + "and for user " + + userName + " and group names " + (groupNames != null ? Arrays.toString(groupNames.toArray()) : "null") + + " is not found."); + } + List matchedParts = new ArrayList<>(); + for(int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) { + matchedParts.add(deepCopy(partitions.get(i))); + } + return matchedParts; + } + + @Override + public List listPartitionNames(String catName, String dbName, String tblName, + int maxParts) throws TException { + org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName); + if (table == null) { + return super.listPartitionNames(catName, dbName, tblName, maxParts); } - List partVals = new ArrayList<>(); - partVals.add(""); //to get all partitions - List parts = tt.getPartitions(partVals); - List matchedParts = new ArrayList<>(); - for(int i = 0; i < (maxParts <= 0 ? parts.size() : maxParts); i++) { - matchedParts.add( - Warehouse.makePartName(tt.tTable.getPartitionKeys(), parts.get(i).getValues())); + TempTable tt = getPartitionedTempTable(table); + List partitions = tt.listPartitions(); + List result = new ArrayList<>(); + for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) { + result.add(makePartName(tt.tTable.getPartitionKeys(), partitions.get(i).getValues())); + } + return result; + } + + @Override + public List listPartitionNames(String catName, String dbName, String tblName, + List partVals, int maxParts) throws TException { + org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName); + if (table == null) { + return super.listPartitionNames(catName, dbName, tblName, partVals, maxParts); + } + TempTable tt = getPartitionedTempTable(table); + List partitions = tt.getPartitionsByPartitionVals(partVals); + List result = new ArrayList<>(); + for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) { + result.add(makePartName(tt.tTable.getPartitionKeys(), partitions.get(i).getValues())); + } + return result; + } + + @Override + public List listPartitions(String catName, String dbName, String tblName, int maxParts) + throws TException { + org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName); + if (table == null) { + return super.listPartitions(catName, dbName, tblName, maxParts); + } + TempTable tt = getPartitionedTempTable(table); + List partitions = tt.listPartitions(); + List matchedParts = new ArrayList<>(); + for(int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) { + matchedParts.add(deepCopy(partitions.get(i))); } return matchedParts; } + @Override + public List listPartitions(String catName, String dbName, String tblName, + List partVals, int maxParts) throws TException { + org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName); + if (table == null) { + return super.listPartitions(catName, dbName, tblName, partVals, maxParts); + } + TempTable tt = getPartitionedTempTable(table); + List partitions = tt.getPartitionsByPartitionVals(partVals); + List matchedParts = new ArrayList<>(); + for(int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) { + matchedParts.add(deepCopy(partitions.get(i))); + } + return matchedParts; + } + + @Override + public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, String tableName, + int maxParts) throws TException { + org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tableName); + if (table == null) { + return super.listPartitionSpecs(catName, dbName, tableName, maxParts); + } + TempTable tt = getPartitionedTempTable(table); + List partitions = tt.listPartitions(); + if (partitions.isEmpty()) { + throw new NoSuchObjectException("Partition for table " + tableName + " in database " + + dbName + " is not found."); + } + List partitionSpecs; + PartitionSpec partitionSpec = new PartitionSpec(); + PartitionListComposingSpec partitionListComposingSpec = new PartitionListComposingSpec(new ArrayList<>()); + for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) { + partitionListComposingSpec.addToPartitions(deepCopy(partitions.get(i))); + } + partitionSpec.setCatName(catName); + partitionSpec.setDbName(dbName); + partitionSpec.setTableName(tableName); + partitionSpec.setRootPath(table.getSd().getLocation()); + partitionSpec.setPartitionList(partitionListComposingSpec); + partitionSpecs = Arrays.asList(partitionSpec); + + return PartitionSpecProxy.Factory.get(partitionSpecs); + } @Override public List getPartitionsByNames(String catName, String dbName, String tblName, @@ -1228,12 +1340,8 @@ public Partition getPartition(String catName, String dbName, String tblName, //(assume) not a temp table - Try underlying client return super.getPartitionsByNames(catName, dbName, tblName, partNames, getColStats); } - assertPartitioned(table); TempTable tt = getPartitionedTempTable(table); - if (tt == null) { - throw new IllegalStateException("TempTable not found for " + - getCatalogQualifiedTableName(table)); - } + List partitions = tt.getPartitionsByNames(partNames); return deepCopyPartitions(partitions); @@ -1247,13 +1355,7 @@ public Partition getPartitionWithAuthInfo(String catName, String dbName, String if (table == null) { return super.getPartitionWithAuthInfo(catName, dbName, tableName, pvals, userName, groupNames); } - assertPartitioned(table); TempTable tt = getPartitionedTempTable(table); - if (tt == null) { - throw new IllegalStateException("TempTable not found for " + - getCatalogQualifiedTableName(table)); - } - Partition partition = tt.getPartitionWithAuthInfo(pvals, userName, groupNames); if (partition == null) { throw new NoSuchObjectException("Partition with partition values " + @@ -1265,7 +1367,7 @@ public Partition getPartitionWithAuthInfo(String catName, String dbName, String return deepCopy(partition); } - private static TempTable getPartitionedTempTable(org.apache.hadoop.hive.metastore.api.Table t) { + private TempTable getPartitionedTempTable(org.apache.hadoop.hive.metastore.api.Table t) throws MetaException { String qualifiedTableName = Warehouse. getQualifiedName(t.getDbName().toLowerCase(), t.getTableName().toLowerCase()); SessionState ss = SessionState.get(); @@ -1273,9 +1375,15 @@ private static TempTable getPartitionedTempTable(org.apache.hadoop.hive.metastor LOG.warn("No current SessionState, skipping temp partitions for " + qualifiedTableName); return null; } - return ss.getTempPartitions().get(qualifiedTableName); + assertPartitioned(t); + TempTable tt = ss.getTempPartitions().get(qualifiedTableName); + if (tt == null) { + throw new IllegalStateException("TempTable not found for " + + getCatalogQualifiedTableName(t)); + } + return tt; } - private static void removeTempTable(org.apache.hadoop.hive.metastore.api.Table t) { + private void removeTempTable(org.apache.hadoop.hive.metastore.api.Table t) { String qualifiedTableName = Warehouse. getQualifiedName(t.getDbName().toLowerCase(), t.getTableName().toLowerCase()); SessionState ss = SessionState.get(); @@ -1285,7 +1393,7 @@ private static void removeTempTable(org.apache.hadoop.hive.metastore.api.Table t } ss.getTempPartitions().remove(Warehouse.getQualifiedName(t)); } - private static void createTempTable(org.apache.hadoop.hive.metastore.api.Table t) { + private void createTempTable(org.apache.hadoop.hive.metastore.api.Table t) { if(t.getPartitionKeysSize() <= 0) { //do nothing as it's not a partitioned table return; diff --git ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetastoreClientListPartitionsTempTable.java ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetastoreClientListPartitionsTempTable.java new file mode 100644 index 0000000000..a74b543faa --- /dev/null +++ ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetastoreClientListPartitionsTempTable.java @@ -0,0 +1,236 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hive.ql.metadata; + +import com.google.common.collect.Lists; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.metastore.IMetaStoreClient; +import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; +import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet; +import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo; +import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.hive.metastore.client.CustomIgnoreRule; +import org.apache.hadoop.hive.metastore.client.TestListPartitions; +import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder; +import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; +import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; +import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy; +import org.apache.hadoop.hive.ql.session.SessionState; +import org.apache.thrift.TException; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * Test class for list partitions related methods on temporary tables. + */ +@RunWith(Parameterized.class) +@Category(MetastoreCheckinTest.class) +public class TestSessionHiveMetastoreClientListPartitionsTempTable + extends TestListPartitions { + + private HiveConf conf; + + private static final String PART_PRIV = "PARTITION_LEVEL_PRIVILEGE"; + + public TestSessionHiveMetastoreClientListPartitionsTempTable(String name, AbstractMetaStoreService metaStore) { + super(name, metaStore); + ignoreRule = new CustomIgnoreRule(); + } + + @Before + public void setUp() throws Exception { + initHiveConf(); + SessionState.start(conf); + setClient(Hive.get(conf).getMSC()); + getClient().dropDatabase(DB_NAME, true, true, true); + getMetaStore().cleanWarehouseDirs(); + } + + private void initHiveConf() throws HiveException { + conf = Hive.get().getConf(); + conf.setBoolVar(HiveConf.ConfVars.METASTORE_FASTPATH, true); + } + + @Override + protected Table createTestTable(IMetaStoreClient client, String dbName, String tableName, + List partCols, boolean setPartitionLevelPrivileges) throws TException { + TableBuilder builder = + new TableBuilder().setDbName(dbName).setTableName(tableName).addCol("id", "int") + .addCol("name", "string").setTemporary(true); + + partCols.forEach(col -> builder.addPartCol(col, "string")); + Table table = builder.build(conf); + + if (setPartitionLevelPrivileges) { + table.putToParameters(PART_PRIV, "true"); + } + + client.createTable(table); + return table; + } + + @Override + protected void addPartition(IMetaStoreClient client, Table table, List values) throws TException { + PartitionBuilder builder = new PartitionBuilder().inTable(table); + values.forEach(builder::addValue); + Partition partition = builder.build(conf); + if (table.getParameters().containsKey(PART_PRIV) && table.getParameters().get(PART_PRIV).equals("true")) { + PrincipalPrivilegeSet privileges = new PrincipalPrivilegeSet(); + Map> userPrivileges = new HashMap<>(); + userPrivileges.put(USER_NAME, new ArrayList<>()); + privileges.setUserPrivileges(userPrivileges); + + Map> groupPrivileges = new HashMap<>(); + groupPrivileges.put(GROUP, new ArrayList<>()); + privileges.setGroupPrivileges(groupPrivileges); + partition.setPrivileges(privileges); + } + client.add_partition(partition); + } + + @Override + protected void assertAuthInfoReturned(String userName, String group, Partition partition) { + PrincipalPrivilegeSet privileges = partition.getPrivileges(); + assertNotNull(privileges); + assertTrue(privileges.getUserPrivileges().containsKey(userName)); + assertTrue(privileges.getGroupPrivileges().containsKey(group)); + } + + @Test + @Override + public void testListPartitionsAllHighMaxParts() throws Exception { + List> testData = createTable4PartColsParts(getClient()); + List partitions = getClient().listPartitions(DB_NAME, TABLE_NAME, (short) 101); + assertFalse(partitions.isEmpty()); + assertEquals(testData.size(), partitions.size()); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionsAllNullTblName() throws Exception { + super.testListPartitionsAllNullTblName(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionsAllNullDbName() throws Exception { + super.testListPartitionsAllNullDbName(); + } + + @Test + @Override + public void testListPartitionSpecsHighMaxParts() throws Exception { + List> testValues = createTable4PartColsParts(getClient()); + PartitionSpecProxy partitionSpecs = getClient().listPartitionSpecs(DB_NAME, TABLE_NAME, 101); + assertNotNull(partitionSpecs); + assertPartitionsSpecProxy(partitionSpecs, testValues); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionSpecsNullTblName() throws Exception { + super.testListPartitionSpecsNullTblName(); + } + + @Test + @Override + public void testListPartitionsWithAuthHighMaxParts() throws Exception { + createTable4PartColsPartsAuthOn(getClient()); + List partitions = + getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short) 101, USER_NAME, Lists.newArrayList(GROUP)); + partitions.forEach(p -> assertAuthInfoReturned(USER_NAME, GROUP, p)); + } + + @Test(expected = NoSuchObjectException.class) + @Override + public void testListPartitionsWithAuthNullGroup() + throws Exception { + super.testListPartitionsWithAuthNullGroup(); + } + + @Test(expected = NoSuchObjectException.class) + @Override + public void testListPartitionsWithAuthByValues() + throws Exception { + super.testListPartitionsWithAuthByValues(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionsWithAuthByValuesNullDbName() + throws Exception { + super.testListPartitionsWithAuthByValuesNullDbName(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionsWithAuthByValuesNullTblName() + throws Exception { + super.testListPartitionsWithAuthByValuesNullTblName(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionNamesNullDbName() throws Exception { + super.testListPartitionNamesNullDbName(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionNamesNullTblName() throws Exception { + super.testListPartitionNamesNullTblName(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionNamesByValuesNullDbName() + throws Exception { + super.testListPartitionNamesByValuesNullDbName(); + } + + @Test(expected = MetaException.class) + @Override + public void testListPartitionNamesByValuesNullTblName() + throws Exception { + super.testListPartitionNamesByValuesNullTblName(); + } + + @Test + @Override + public void testListPartitionsWithAuthNoTable() throws Exception { + getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short)-1, "", Lists.newArrayList()); + } + +} diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java index 99039b08d0..baa1a6f8df 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java @@ -25,7 +25,7 @@ import java.lang.annotation.Target; /** - * This annotation provides a way to skip the execution of seome tests, + * This annotation provides a way to skip the execution of some tests, * when a certain runtime criteria is met. It should be used together with {@link CustomIgnoreRule}. */ @Retention(RetentionPolicy.RUNTIME) diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java index 34ceb34de6..cb7220713d 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java @@ -74,8 +74,10 @@ private AbstractMetaStoreService metaStore; private IMetaStoreClient client; - private static final String DB_NAME = "testpartdb"; - private static final String TABLE_NAME = "testparttable"; + protected static final String DB_NAME = "testpartdb"; + protected static final String TABLE_NAME = "testparttable"; + protected static final String USER_NAME = "user0"; + protected static final String GROUP = "group0"; public TestListPartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; @@ -89,6 +91,7 @@ public void setUp() throws Exception { // Clean up the database client.dropDatabase(DB_NAME, true, true, true); createDB(DB_NAME); + } @After @@ -106,6 +109,22 @@ public void tearDown() throws Exception { } } + protected AbstractMetaStoreService getMetaStore() { + return metaStore; + } + + protected void setMetaStore(AbstractMetaStoreService metaStore) { + this.metaStore = metaStore; + } + + protected IMetaStoreClient getClient() { + return client; + } + + protected void setClient(IMetaStoreClient client) { + this.client = client; + } + private void createDB(String dbName) throws TException { new DatabaseBuilder(). setName(dbName). @@ -119,7 +138,7 @@ private Table createTestTable(IMetaStoreClient client, String dbName, String tab } - private Table createTestTable(IMetaStoreClient client, String dbName, String tableName, + protected Table createTestTable(IMetaStoreClient client, String dbName, String tableName, List partCols, boolean setPartitionLevelPrivilages) throws TException { TableBuilder builder = new TableBuilder() @@ -139,7 +158,7 @@ private Table createTestTable(IMetaStoreClient client, String dbName, String tab return table; } - private void addPartition(IMetaStoreClient client, Table table, List values) + protected void addPartition(IMetaStoreClient client, Table table, List values) throws TException { PartitionBuilder partitionBuilder = new PartitionBuilder().inTable(table); values.forEach(val -> partitionBuilder.addValue(val)); @@ -153,7 +172,7 @@ private void createTable3PartCols1PartGeneric(IMetaStoreClient client, boolean a addPartition(client, t, Lists.newArrayList("1997", "05", "16")); } - private void createTable3PartCols1Part(IMetaStoreClient client) throws TException { + protected void createTable3PartCols1Part(IMetaStoreClient client) throws TException { createTable3PartCols1PartGeneric(client, false); } @@ -175,17 +194,17 @@ private void createTable3PartCols1Part(IMetaStoreClient client) throws TExceptio return testValues; } - private List> createTable4PartColsParts(IMetaStoreClient client) throws + protected List> createTable4PartColsParts(IMetaStoreClient client) throws Exception { return createTable4PartColsPartsGeneric(client, false); } - private List> createTable4PartColsPartsAuthOn(IMetaStoreClient client) throws + protected List> createTable4PartColsPartsAuthOn(IMetaStoreClient client) throws Exception { return createTable4PartColsPartsGeneric(client, true); } - private static void assertAuthInfoReturned(String user, String group, Partition partition) { + protected void assertAuthInfoReturned(String user, String group, Partition partition) { assertNotNull(partition.getPrivileges()); assertEquals(Lists.newArrayList(), partition.getPrivileges().getUserPrivileges().get(user)); @@ -195,15 +214,17 @@ private static void assertAuthInfoReturned(String user, String group, Partition partition.getPrivileges().getRolePrivileges().get("public")); } - private static void assertPartitionsHaveCorrectValues(List partitions, + private void assertPartitionsHaveCorrectValues(List partitions, List> testValues) throws Exception { assertEquals(testValues.size(), partitions.size()); + partitions.forEach(p -> {}); + for (int i = 0; i < partitions.size(); ++i) { assertEquals(testValues.get(i), partitions.get(i).getValues()); } } - private static void assertCorrectPartitionNames(List names, + private void assertCorrectPartitionNames(List names, List> testValues, ListpartCols) throws Exception { assertEquals(testValues.size(), names.size()); @@ -216,7 +237,7 @@ private static void assertCorrectPartitionNames(List names, } } - private static void assertPartitionsSpecProxy(PartitionSpecProxy partSpecProxy, + protected void assertPartitionsSpecProxy(PartitionSpecProxy partSpecProxy, List> testValues) throws Exception { assertEquals(testValues.size(), partSpecProxy.size()); List partitionSpecs = partSpecProxy.toPartitionSpec(); @@ -228,7 +249,7 @@ private static void assertPartitionsSpecProxy(PartitionSpecProxy partSpecProxy, } } - private static void assertCorrectPartitionValuesResponse(List> testValues, + private void assertCorrectPartitionValuesResponse(List> testValues, PartitionValuesResponse resp) throws Exception { assertEquals(testValues.size(), resp.getPartitionValuesSize()); List rowList = resp.getPartitionValues(); @@ -478,19 +499,18 @@ public void testListPartitionSpecsNullTblName() throws Exception { @Test public void testListPartitionsWithAuth() throws Exception { List> partValues = createTable4PartColsPartsAuthOn(client); - String user = "user0"; - List groups = Lists.newArrayList("group0"); + List groups = Lists.newArrayList(GROUP); List partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short)-1, - user, groups); + USER_NAME, groups); assertEquals(4, partitions.size()); assertPartitionsHaveCorrectValues(partitions, partValues); - partitions.forEach(partition -> assertAuthInfoReturned(user, groups.get(0), partition)); + partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, groups.get(0), partition)); - partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short)2, user, groups); + partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short)2, USER_NAME, groups); assertEquals(2, partitions.size()); assertPartitionsHaveCorrectValues(partitions, partValues.subList(0, 2)); - partitions.forEach(partition -> assertAuthInfoReturned(user, groups.get(0), partition)); + partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, groups.get(0), partition)); } @Test(expected = MetaException.class) @@ -499,6 +519,18 @@ public void testListPartitionsWithAuthHighMaxParts() throws Exception { client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short)101, "", Lists.newArrayList()); } + @Test + public void testListPartitionsWithAuthLowMaxParts() throws Exception { + createTable4PartColsPartsAuthOn(getClient()); + List partitions = + getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short) 2, USER_NAME, Lists.newArrayList(GROUP)); + assertTrue(partitions.size() == 2); + partitions.forEach(p -> assertAuthInfoReturned(USER_NAME, GROUP, p)); + partitions = getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short) -1, USER_NAME, Lists.newArrayList(GROUP)); + assertTrue(partitions.size() == 4); + partitions.forEach(p -> assertAuthInfoReturned(USER_NAME, GROUP, p)); + } + @Test public void testListPartitionsWithAuthNoPrivilegesSet() throws Exception { List> partValues = createTable4PartColsParts(client); @@ -573,29 +605,28 @@ public void testListPartitionsWithAuthNullGroup() throws Exception { @Test public void testListPartitionsWithAuthByValues() throws Exception { List> partValues = createTable4PartColsPartsAuthOn(client); - String user = "user0"; - List groups = Lists.newArrayList("group0"); + List groups = Lists.newArrayList(GROUP); List partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists - .newArrayList("2017", "11", "27"), (short)-1, user, groups); + .newArrayList("2017", "11", "27"), (short)-1, USER_NAME, groups); assertEquals(1, partitions.size()); assertPartitionsHaveCorrectValues(partitions, partValues.subList(3, 4)); - partitions.forEach(partition -> assertAuthInfoReturned(user, groups.get(0), partition)); + partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, groups.get(0), partition)); partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists - .newArrayList("2017"), (short)-1, user, groups); + .newArrayList("2017"), (short)-1, USER_NAME, groups); assertEquals(2, partitions.size()); assertPartitionsHaveCorrectValues(partitions, partValues.subList(2, 4)); - partitions.forEach(partition -> assertAuthInfoReturned(user, groups.get(0), partition)); + partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, groups.get(0), partition)); partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists - .newArrayList("2017"), (short)1, user, groups); + .newArrayList("2017"), (short)1, USER_NAME, groups); assertEquals(1, partitions.size()); assertPartitionsHaveCorrectValues(partitions, partValues.subList(2, 3)); - partitions.forEach(partition -> assertAuthInfoReturned(user, groups.get(0), partition)); + partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, groups.get(0), partition)); partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists - .newArrayList("2013"), (short)-1, user, groups); + .newArrayList("2013"), (short)-1, USER_NAME, groups); assertTrue(partitions.isEmpty()); } @@ -723,7 +754,9 @@ public void testListPartitionsWithAuthByValuesNullGroup() throws Exception { * Testing listPartitionsByFilter(String,String,String,short) -> * get_partitions_by_filter(String,String,String,short). */ + @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilter() throws Exception { List> partValues = createTable4PartColsParts(client); List partitions = client.listPartitionsByFilter(DB_NAME, TABLE_NAME, @@ -746,6 +779,7 @@ public void testListPartitionsByFilter() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterCaseInsensitive() throws Exception { String tableName = TABLE_NAME + "_caseinsensitive"; Table t = createTestTable(client, DB_NAME, tableName, @@ -788,6 +822,7 @@ public void testListPartitionsByFilterCaseInsensitive() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterCaseSensitive() throws Exception { String tableName = TABLE_NAME + "_casesensitive"; Table t = createTestTable(client, DB_NAME, tableName, @@ -823,41 +858,48 @@ public void testListPartitionsByFilterCaseSensitive() throws Exception { } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterInvalidFilter() throws Exception { createTable4PartColsParts(client); client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyy=\"2017\"", (short)101); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterHighMaxParts() throws Exception { createTable4PartColsParts(client); client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", (short)101); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNoTblName() throws Exception { createTable4PartColsParts(client); client.listPartitionsByFilter(DB_NAME, "", "yyyy=\"2017\"", (short)-1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNoDbName() throws Exception { createTable4PartColsParts(client); client.listPartitionsByFilter("", TABLE_NAME, "yyyy=\"2017\"", (short)-1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNoTable() throws Exception { client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", (short)-1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNoDb() throws Exception { client.dropDatabase(DB_NAME); client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", (short)-1); } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNullTblName() throws Exception { try { createTable4PartColsParts(client); @@ -869,6 +911,7 @@ public void testListPartitionsByFilterNullTblName() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNullDbName() throws Exception { try { createTable4PartColsParts(client); @@ -880,6 +923,7 @@ public void testListPartitionsByFilterNullDbName() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterNullFilter() throws Exception { createTable4PartColsParts(client); List partitions = client.listPartitionsByFilter(DB_NAME, TABLE_NAME, null, @@ -888,6 +932,7 @@ public void testListPartitionsByFilterNullFilter() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsByFilterEmptyFilter() throws Exception { createTable4PartColsParts(client); List partitions = client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "", (short)-1); @@ -901,6 +946,7 @@ public void testListPartitionsByFilterEmptyFilter() throws Exception { * get_part_specs_by_filter(String,String,String,int). */ @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionsSpecsByFilter() throws Exception { List> testValues = createTable4PartColsParts(client); PartitionSpecProxy partSpecProxy = client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, @@ -933,53 +979,62 @@ public void testListPartitionsSpecsByFilter() throws Exception { } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterInvalidFilter() throws Exception { createTable4PartColsParts(client); client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyy=\"2017\"", 101); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterHighMaxParts() throws Exception { createTable4PartColsParts(client); client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 101); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNoTblName() throws Exception { createTable4PartColsParts(client); client.listPartitionSpecsByFilter(DB_NAME, "", "yyyy=\"2017\"", -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNoDbName() throws Exception { createTable4PartColsParts(client); client.listPartitionSpecsByFilter("", TABLE_NAME, "yyyy=\"2017\"", -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNoTable() throws Exception { client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNoDb() throws Exception { client.dropDatabase(DB_NAME); client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", -1); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNullTblName() throws Exception { createTable4PartColsParts(client); client.listPartitionSpecsByFilter(DB_NAME, null, "yyyy=\"2017\"", -1); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNullDbName() throws Exception { createTable4PartColsParts(client); client.listPartitionSpecsByFilter(null, TABLE_NAME, "yyyy=\"2017\"", -1); } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterNullFilter() throws Exception { List> values = createTable4PartColsParts(client); PartitionSpecProxy pproxy = client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, null, -1); @@ -987,6 +1042,7 @@ public void testListPartitionSpecsByFilterNullFilter() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionSpecsByFilterEmptyFilter() throws Exception { List> values = createTable4PartColsParts(client); PartitionSpecProxy pproxy = client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "", -1); @@ -1000,6 +1056,7 @@ public void testListPartitionSpecsByFilterEmptyFilter() throws Exception { * get_num_partitions_by_filter(String,String,String). */ @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilter() throws Exception { createTable4PartColsParts(client); int n = client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\" OR " + @@ -1024,47 +1081,55 @@ public void testGetNumPartitionsByFilter() throws Exception { } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterInvalidFilter() throws Exception { createTable4PartColsParts(client); client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyy=\"2017\""); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNoTblName() throws Exception { createTable4PartColsParts(client); client.getNumPartitionsByFilter(DB_NAME, "", "yyyy=\"2017\""); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNoDbName() throws Exception { createTable4PartColsParts(client); client.getNumPartitionsByFilter("", TABLE_NAME, "yyyy=\"2017\""); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNoTable() throws Exception { client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\""); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNoDb() throws Exception { client.dropDatabase(DB_NAME); client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\""); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNullTblName() throws Exception { createTable4PartColsParts(client); client.getNumPartitionsByFilter(DB_NAME, null, "yyyy=\"2017\""); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNullDbName() throws Exception { createTable4PartColsParts(client); client.getNumPartitionsByFilter(null, TABLE_NAME, "yyyy=\"2017\""); } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testGetNumPartitionsByFilterNullFilter() throws Exception { createTable4PartColsParts(client); int n = client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, null); @@ -1188,6 +1253,21 @@ public void testListPartitionNamesByValuesMaxPartCountUnlimited() throws Excepti Lists.newArrayList("yyyy", "mm", "dd")); } + @Test + public void testListPartitionNamesByValuesLowPartCount() throws Exception { + List> testValues = createTable4PartColsParts(client); + List partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, + Lists.newArrayList("2017"), (short) 1); + assertTrue(partitionNames.size() == 1); + assertCorrectPartitionNames(partitionNames, testValues.subList(2 , 3), + Lists.newArrayList("yyyy", "mm", "dd")); + partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, + Lists.newArrayList("2017"), (short) -1); + assertTrue(partitionNames.size() == 2); + assertCorrectPartitionNames(partitionNames, testValues.subList(2, 4), + Lists.newArrayList("yyyy", "mm", "dd")); + } + @Test(expected = MetaException.class) public void testListPartitionNamesByValuesNoPartVals() throws Exception { createTable4PartColsParts(client); @@ -1259,6 +1339,7 @@ public void testListPartitionNamesByValuesNullValues() throws Exception { * get_partition_values(PartitionValuesRequest). */ @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValues() throws Exception { List> testValues = createTable4PartColsParts(client); List partitionSchema = Lists.newArrayList( @@ -1273,6 +1354,7 @@ public void testListPartitionValues() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesEmptySchema() throws Exception { try { List> testValues = createTable4PartColsParts(client); @@ -1288,6 +1370,7 @@ public void testListPartitionValuesEmptySchema() throws Exception { } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNoDbName() throws Exception { createTable4PartColsParts(client); List partitionSchema = Lists.newArrayList( @@ -1300,6 +1383,7 @@ public void testListPartitionValuesNoDbName() throws Exception { } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNoTblName() throws Exception { createTable4PartColsParts(client); List partitionSchema = Lists.newArrayList( @@ -1312,6 +1396,7 @@ public void testListPartitionValuesNoTblName() throws Exception { } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNoTable() throws Exception { List partitionSchema = Lists.newArrayList( new FieldSchema("yyyy", "string", ""), @@ -1323,6 +1408,7 @@ public void testListPartitionValuesNoTable() throws Exception { } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNoDb() throws Exception { client.dropDatabase(DB_NAME); List partitionSchema = Lists.newArrayList( @@ -1335,6 +1421,7 @@ public void testListPartitionValuesNoDb() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNullDbName() throws Exception { try { createTable4PartColsParts(client); @@ -1352,6 +1439,7 @@ public void testListPartitionValuesNullDbName() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNullTblName() throws Exception { try { createTable4PartColsParts(client); @@ -1369,6 +1457,7 @@ public void testListPartitionValuesNullTblName() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNullSchema() throws Exception { try { createTable4PartColsParts(client); @@ -1382,6 +1471,7 @@ public void testListPartitionValuesNullSchema() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void testListPartitionValuesNullRequest() throws Exception { try { createTable4PartColsParts(client); @@ -1393,6 +1483,7 @@ public void testListPartitionValuesNullRequest() throws Exception { } @Test + @ConditionalIgnoreOnSessionHiveMetastoreClient public void otherCatalog() throws TException { String catName = "list_partition_catalog"; Catalog cat = new CatalogBuilder() @@ -1464,54 +1555,63 @@ public void otherCatalog() throws TException { } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionsBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitions("bogus", DB_NAME, TABLE_NAME, -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionsWithPartialValuesBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitions("bogus", DB_NAME, TABLE_NAME, Collections.singletonList("a0"), -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionsSpecsBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionSpecs("bogus", DB_NAME, TABLE_NAME, -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionsByFilterBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionsByFilter("bogus", DB_NAME, TABLE_NAME, "partcol=\"a0\"", -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionSpecsByFilterBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionSpecsByFilter("bogus", DB_NAME, TABLE_NAME, "partcol=\"a0\"", -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void getNumPartitionsByFilterBogusCatalog() throws TException { createTable3PartCols1Part(client); client.getNumPartitionsByFilter("bogus", DB_NAME, TABLE_NAME, "partcol=\"a0\""); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionNamesBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionNames("bogus", DB_NAME, TABLE_NAME, -1); } @Test(expected = NoSuchObjectException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionNamesPartialValsBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionNames("bogus", DB_NAME, TABLE_NAME, Collections.singletonList("a0"), -1); } @Test(expected = MetaException.class) + @ConditionalIgnoreOnSessionHiveMetastoreClient public void listPartitionValuesBogusCatalog() throws TException { createTable3PartCols1Part(client); PartitionValuesRequest rqst = new PartitionValuesRequest(DB_NAME,