You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2021/05/03 17:20:09 UTC

[GitHub] [phoenix] swaroopak commented on a change in pull request #1215: PHOENIX-6387 Conditional updates on tables with indexes

swaroopak commented on a change in pull request #1215:
URL: https://github.com/apache/phoenix/pull/1215#discussion_r625237976



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java
##########
@@ -498,18 +508,29 @@ public void run() {
         exec.shutdownNow();
 
         int finalResult = nThreads * nCommits * nIncrementsPerCommit;
-        //assertEquals(finalResult,resultHolder[0]);
-        ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE counter1 >= 0");
+        boolean isIndexCreated = this.indexDDL != null && this.indexDDL.length() > 0;
+
+        ResultSet rs;
+        String selectSql = "SELECT * FROM " + tableName + " WHERE counter1 >= 0";
+        if (isIndexCreated) {
+            rs = conn.createStatement().executeQuery("EXPLAIN " + selectSql);
+            String actualExplainPlan = QueryUtil.getExplainPlan(rs);
+            IndexToolIT.assertExplainPlan(this.indexDDL.contains("local"), actualExplainPlan,
+                tableName, tableName + "_IDX");
+        }
+        rs = conn.createStatement().executeQuery(selectSql);
         assertTrue(rs.next());
         assertEquals("a",rs.getString(1));
         assertEquals(finalResult,rs.getInt(2));
         assertFalse(rs.next());
 
-        rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ * FROM " + tableName + " WHERE counter1 >= 0");
-        assertTrue(rs.next());
-        assertEquals("a",rs.getString(1));
-        assertEquals(finalResult,rs.getInt(2));
-        assertFalse(rs.next());
+        if (isIndexCreated) {
+            rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ * FROM " + tableName + " WHERE counter1 >= 0");

Review comment:
       Why not use the index if the index is created?




-- 
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.

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