saihemanth-cloudera commented on code in PR #4726: URL: https://github.com/apache/hive/pull/4726#discussion_r1367382092
########## ql/src/test/org/apache/hadoop/hive/metastore/TestListPartitionsWithXIncludeParams.java: ########## @@ -0,0 +1,234 @@ +/* + * 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.metastore; + +import com.google.common.collect.Lists; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; +import org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest; +import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec; +import org.apache.hadoop.hive.metastore.api.GetPartitionsRequest; +import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec; +import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.PartitionFilterMode; +import org.apache.hadoop.hive.metastore.api.PartitionWithoutSD; +import org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest; +import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.hive.metastore.client.TestListPartitions; +import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; +import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils; +import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils; +import org.apache.hadoop.hive.ql.exec.SerializationUtilities; +import org.apache.hadoop.hive.ql.optimizer.ppr.PartitionExpressionForMetastore; +import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; +import org.apache.thrift.TException; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static junit.framework.TestCase.assertTrue; +import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.convertToGetPartitionsByNamesRequest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +/** + * Test class for list partitions with configurable include/exclude pattern on parameters. + * Embedded Metastore uses JDO, Remote Metastore uses direct SQL to query the partitions: + * MetaStoreFactoryForTests.getMetaStores() + */ +@RunWith(Parameterized.class) +@Category(MetastoreCheckinTest.class) +public class TestListPartitionsWithXIncludeParams + extends TestListPartitions { + + private Configuration hiveConf; + private Set<String> includeKeys = new HashSet<>(); + private Set<String> excludeKeys = new HashSet<>(); + private Map<String, String> partParams = new HashMap<>(); + + public static class PartitionExpressionForMetastoreTest extends PartitionExpressionForMetastore { + // MetaStoreTestUtils.setConfForStandloneMode will change the default PartitionExpressionForMetastore + // to DefaultPartitionExpressionProxy, which doesn't support deserializing the Hive filter from a byte array. + // As this test sits inside the hive-exec module, it's safe to set the hive.metastore.expression.proxy to + // PartitionExpressionForMetastoreTest. + } + + public TestListPartitionsWithXIncludeParams(String name, + AbstractMetaStoreService metaStore) { + super(name, metaStore); + partParams.put("key1", "value1"); + partParams.put("akey1", "avalue1"); + partParams.put("akey10", "avalue10"); + partParams.put("excludekey1", "value1"); + partParams.put("excludekey2", "value1"); + includeKeys.add("key1"); + includeKeys.add("akey1"); + excludeKeys.add("excludekey1"); + excludeKeys.add("excludekey2"); + hiveConf = metaStore.getConf(); + MetastoreConf.setVar(hiveConf, MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS, + PartitionExpressionForMetastoreTest.class.getName()); + MetastoreConf.setVar(hiveConf, + MetastoreConf.ConfVars.METASTORE_PARTITIONS_PARAMETERS_INCLUDE_PATTERN, "%k_y_"); Review Comment: I see, so exclude pattern has higher priority compared to include pattern -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org