kadirozde commented on a change in pull request #600: PHOENIX-5535 Index 
rebuilds via UngroupedAggregateRegionObserver shou…
URL: https://github.com/apache/phoenix/pull/600#discussion_r337122879
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
 ##########
 @@ -251,6 +252,61 @@ public void testSecondaryIndex() throws Exception {
         }
     }
 
+    private void setWithNull(int nrows, int nthRowNull, PreparedStatement 
stmt) throws Exception {
+        for (int i = 0; i < nrows; i++) {
+            stmt.setInt(1, i);
+            stmt.setInt(2, i * 10);
+            if (i % nthRowNull != 0) {
+                stmt.setInt(3, 9000 + i);
+            } else {
+                stmt.setNull(3, Types.INTEGER);
+            }
+            stmt.execute();
+        }
+    }
+
+    @Test
+    public void testWithSetNull() throws Exception {
+        // This test is for building non-transactional global indexes with 
direct api
+        if (localIndex || transactional) {
+            return;
+        }
+        final int NROWS = 100;
+
+        String schemaName = generateUniqueName();
+        String dataTableName = generateUniqueName();
+        String dataTableFullName = SchemaUtil.getTableName(schemaName, 
dataTableName);
+        String indexTableName = generateUniqueName();
+        String indexTableFullName = SchemaUtil.getTableName(schemaName, 
indexTableName);
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+            String stmString1 =
+                    "CREATE TABLE " + dataTableFullName
+                            + " (ID INTEGER NOT NULL PRIMARY KEY, VAL INTEGER, 
ZIP INTEGER) "
+                            + tableDDLOptions;
+            conn.createStatement().execute(stmString1);
+            String upsertStmt = "UPSERT INTO " + dataTableFullName + " 
VALUES(?,?,?)";
+            PreparedStatement stmt = conn.prepareStatement(upsertStmt);
+            setWithNull(NROWS, 3, stmt);
+            conn.commit();
+            setWithNull(NROWS, 5, stmt);
+            conn.commit();
+
+            String stmtString2 =
+                    String.format(
+                            "CREATE %s INDEX %s ON %s (VAL) INCLUDE (ZIP) 
ASYNC ",
+                            (localIndex ? "LOCAL" : ""), indexTableName, 
dataTableFullName);
+            conn.createStatement().execute(stmtString2);
+
+            // Run the index MR job and verify that the index table is built 
correctly
+            IndexTool indexTool = runIndexTool(directApi, useSnapshot, 
schemaName, dataTableName, indexTableName, null, 0, new String[0]);
+            assertEquals(NROWS, 
indexTool.getJob().getCounters().findCounter(INPUT_RECORDS).getValue());
+            long actualRowCount = IndexScrutiny.scrutinizeIndex(conn, 
dataTableFullName, indexTableFullName);
+            assertEquals(NROWS, actualRowCount);
+        }
+    }
+
+
 
 Review comment:
   @gjacoby126, I am not sure if you have seen my comments on the JIRA. I have 
pointed out that this patch is not sufficient as compaction will remove delete 
markers. Would you please read my comments there and reply? 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to