nizhikov commented on a change in pull request #9618:
URL: https://github.com/apache/ignite/pull/9618#discussion_r774642965



##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexTest.java
##########
@@ -1518,6 +1521,50 @@ public void testCreateLuceneIndex() throws Exception {
 
         assertNull(GridTestUtils.getFieldValue(tblDesc1, "luceneIdx"));
     }
+    
+    /**
+     * Checks that part of the composite key assembled in BinaryObjectBuilder 
can pass the validation correctly
+     * if you specify Object type when creating the index.
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testCacheSecondaryCompositeIndex() throws Exception {
+        inlineSize = 70;
+        
+        startGrid();
+        
+        String cacheName = "TEST";
+
+        List<QueryIndex> indexes = Collections.singletonList(
+            new QueryIndex("val_obj", 
QueryIndexType.SORTED).setInlineSize(inlineSize)
+        );
+
+        grid().createCache(new CacheConfiguration<>()
+            .setName(cacheName)
+            .setSqlSchema(cacheName)
+            .setAffinity(new RendezvousAffinityFunction(false, 4))
+            .setQueryEntities(Collections.singleton(new QueryEntity()
+                .setTableName(cacheName)
+                .setKeyType(Integer.class.getName())
+                .setKeyFieldName("id")
+                .setValueType("TEST_VAL_SECONDARY_COMPOSITE")
+                .addQueryField("id", Integer.class.getName(), null)
+                .addQueryField("val_obj", Object.class.getName(), null)
+                .setIndexes(indexes)
+            ))
+        );
+        
+        BinaryObjectBuilder bob = 
grid().binary().builder("TEST_VAL_SECONDARY_COMPOSITE");
+        BinaryObjectBuilder bobInner = grid().binary().builder("inner");
+        
+        bobInner.setField("inner_k", 0);
+        bobInner.setField("inner_uuid", UUID.randomUUID());
+        
+        bob.setField("val_obj", bobInner.build());
+        
+        grid().cache(cacheName).put(0, bob.build());

Review comment:
       ```suggestion
           IgniteCache<Object, Object> cache = grid().cache(cacheName);
   
           cache.put(0, bob.build());
   
           BinaryObjectBuilder alice = 
grid().binary().builder("TEST_VAL_SECONDARY_COMPOSITE");
           BinaryObjectBuilder aliceInner = grid().binary().builder("inner2");
   
           aliceInner.setField("inner_k2", 0);
           aliceInner.setField("inner_uuid2", UUID.randomUUID());
   
           alice.setField("val_obj", aliceInner.build());
   
           cache.put(1, alice.build());
   
           List<List<?>> rows = execSql(cache.withKeepBinary(), "SELECT id, 
val_obj FROM " + cacheName);
   
           assertEquals(2, rows.size());
   
           for (List<?> row : rows) {
               assertNotNull(row.get(0));
               assertNotNull("id = " + row.get(0), row.get(1));
           }
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to