albertogpz commented on a change in pull request #6110:
URL: https://github.com/apache/geode/pull/6110#discussion_r592166331



##########
File path: 
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/CompactRangeIndexJUnitTest.java
##########
@@ -442,6 +445,48 @@ public void doTestHook(final SPOTS spot, final 
DefaultQuery _ignored,
     }
   }
 
+  /**
+   * Tests adding entries to compact range index where there are undefined and 
null values
+   * for the key
+   */
+  @Test
+  public void testNullAndUndefinedValuesForMapKeyInCompactRangeIndex() throws 
Exception {
+    index = utils.createIndex("indexName", "positions['SUN']", SEPARATOR + 
"exampleRegion");
+    Region<Object, Object> region = 
utils.getCache().getRegion("exampleRegion");
+
+    // create objects
+    Portfolio p1 = new Portfolio(1);
+    p1.positions = new HashMap<>();
+    p1.positions.put("SUN", "yes");
+    region.put("KEY-" + 1, p1);
+
+    // Equivalent to having a null value for positions['SUN'] when querying
+    Portfolio p2 = new Portfolio(2);
+    p2.positions = new HashMap<>();
+    p2.positions.put("ERIC", 2);
+    region.put("KEY-" + 2, p2);
+
+    // Undefined value for positions['SUN'] when querying
+    Portfolio p3 = new Portfolio(3);
+    p3.positions = null;
+    region.put("KEY-" + 3, p3);
+
+    // null value for positions['SUN']
+    Portfolio p4 = new Portfolio(4);
+    p4.positions = new HashMap<>();
+    p4.positions.put("SUN", null);
+    region.put("KEY-" + 4, p4);
+
+    // execute query and check result size
+    QueryService qs = utils.getCache().getQueryService();
+    SelectResults<Object> results = UncheckedUtils.uncheckedCast(qs
+        .newQuery(
+            "Select * from " + SEPARATOR + "exampleRegion r where 
r.positions['SUN'] = null")
+        .execute());
+    assertThat(results.size()).isEqualTo(2);

Review comment:
       ok




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


Reply via email to