You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "stoty (via GitHub)" <gi...@apache.org> on 2023/05/19 02:56:53 UTC

[GitHub] [phoenix] stoty commented on a diff in pull request #1607: PHOENIX-6910 Scans created during query compilation and execution aga…

stoty commented on code in PR #1607:
URL: https://github.com/apache/phoenix/pull/1607#discussion_r1198495896


##########
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:
   Random values in tests are fishy.
   We could increase the number of rows, and check that we get back each of them.
   It's a bit tricky, as the nature of hashing makes it hard to make sure that we cover all buckets.
   



-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org