virajjasani commented on code in PR #1607: URL: https://github.com/apache/phoenix/pull/1607#discussion_r1198227179
########## phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableMergeBucketsIT.java: ########## @@ -0,0 +1,103 @@ +/* + * 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.phoenix.end2end.salted; + +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.List; +import java.util.Properties; + +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.phoenix.end2end.ParallelStatsDisabledIT; +import org.apache.phoenix.end2end.ParallelStatsDisabledTest; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.TestUtil; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(ParallelStatsDisabledTest.class) +public class SaltedTableMergeBucketsIT extends ParallelStatsDisabledIT { + + @Test + public void testQuery() throws Exception { + String tableName = generateUniqueName(); + + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.FALSE.toString()); + Connection connection = DriverManager.getConnection(getUrl(), props); + Statement statement = connection.createStatement(); + statement.execute("CREATE TABLE " + tableName + + " (c1 VARCHAR NOT NULL, c2 VARCHAR NOT NULL, c3 VARCHAR NOT NULL," + + " CONSTRAINT pk PRIMARY KEY(c1,c2,c3)) SALT_BUCKETS=11"); + statement.execute( + " upsert into " + tableName + " values('20191211','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191212','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191213','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191214','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191215','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191216','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191217','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191218','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191219','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191220','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191221','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191222','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191223','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191224','HORTONWORKS_WEEKLY_TEST','v3')"); + statement.execute( + " upsert into " + tableName + " values('20191225','HORTONWORKS_WEEKLY_TEST','v3')"); + connection.commit(); + + Admin admin = + driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + List<RegionInfo> regions = admin.getRegions(TableName.valueOf(tableName)); + for (int i = 0; i < regions.size() - 1; i+=2) { + admin.mergeRegionsAsync(regions.get(i).getEncodedNameAsBytes(), + regions.get(i + 1).getEncodedNameAsBytes(), false).get(); + } + ResultSet rs = + statement.executeQuery("select c1,c2,c3 from " + tableName + + " where c1='20191211' and c2 like '%HORTONWORKS_WEEKLY_TEST%'"); + assertTrue(rs.next()); + rs = + statement.executeQuery("select c1,c2,c3 from " + tableName + + " where c1='20191217' and c2 like '%HORTONWORKS_WEEKLY_TEST%'"); Review Comment: shall we pick random c1 values from a list of values instead of only with `20191211` and `20191217`? we can create a list with multiple values and try using UPSERT in a loop against the list, that will reduce num of unique UPSERT statements we need to run in the test and also facilitate querying against any random c1 values from the given list. ########## phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableMergeBucketsIT.java: ########## @@ -0,0 +1,103 @@ +/* + * 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.phoenix.end2end.salted; + +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.List; +import java.util.Properties; + +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.phoenix.end2end.ParallelStatsDisabledIT; +import org.apache.phoenix.end2end.ParallelStatsDisabledTest; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.TestUtil; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(ParallelStatsDisabledTest.class) +public class SaltedTableMergeBucketsIT extends ParallelStatsDisabledIT { Review Comment: shall we make this `SaltedTableSplitMergeBucketsIT` and add another test that does splitting of salted table region and then verify the result of SELECT queries against randomly picked key values from UPSERT queries? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
