kadirozde commented on code in PR #2097:
URL: https://github.com/apache/phoenix/pull/2097#discussion_r2017514417


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexCheckerIT.java:
##########
@@ -1223,6 +1245,166 @@ public void 
testUnverifiedIndexRowWithFirstKeyOnlyFilter() throws Exception {
         }
     }
 
+    @Test
+    public void testIndexRowWithNullIncludedColumnAndFilter() throws Exception 
{
+        if (async) {
+            // No need to run the same test twice one for async = true and the 
other for async = false
+            return;
+        }
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            String dataTableName = generateUniqueName();
+            String indexName = generateUniqueName();
+            // with two rows ('a', 'ab', 'abc', 'abcd') and ('b', 'bc', 'bcd', 
'bcde')
+            populateTable(dataTableName);
+            conn.createStatement().execute("CREATE INDEX " + indexName + " on 
" +
+                   dataTableName + "  (val1) include (val2, val3)" + 
indexDDLOptions);
+            conn.commit();
+            // update row ('a', 'ab', 'abc', 'abcd') -> ('a', 'ab', 'abc', 
null)
+            conn.createStatement().execute(
+                    "upsert into " + dataTableName + " (id, val3) values ('a', 
null)");
+            conn.commit();
+
+            String dql = String.format(
+                    "select id, val2 from %s where val1='ab' and val3='abcd'", 
dataTableName);
+            try (ResultSet rs = conn.createStatement().executeQuery(dql)) {
+                PhoenixResultSet prs = rs.unwrap(PhoenixResultSet.class);
+                String explainPlan = 
QueryUtil.getExplainPlan(prs.getUnderlyingIterator());
+                assertTrue(explainPlan.contains(indexName));
+                assertFalse(rs.next());
+            }
+
+            dql = String.format(
+                    "select id, val2 from %s where val1='ab' and val3 is 
null", dataTableName);
+            try (ResultSet rs = conn.createStatement().executeQuery(dql)) {
+                PhoenixResultSet prs = rs.unwrap(PhoenixResultSet.class);
+                String explainPlan = 
QueryUtil.getExplainPlan(prs.getUnderlyingIterator());
+                assertTrue(explainPlan.contains(indexName));
+                assertTrue(rs.next());
+                assertEquals("abc", rs.getString("val2"));
+            }
+
+            // update row ('a', 'ab', 'abc', null) -> ('a', 'ac', null, null)
+            conn.createStatement().execute(
+                    "upsert into " + dataTableName + " values ('a', 'ac', 
null, null)");

Review Comment:
   val 3 was null already. We should skip updating it again.



-- 
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-unsubscr...@phoenix.apache.org

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

Reply via email to