You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/05/14 21:16:07 UTC

[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #6918: Convert collections not unnested to json

siddharthteotia commented on a change in pull request #6918:
URL: https://github.com/apache/incubator-pinot/pull/6918#discussion_r632812214



##########
File path: pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/ComplexTypeTransformerTest.java
##########
@@ -237,4 +238,76 @@ public void testUnnestCollection() {
     next = itr.next();
     Assert.assertEquals("v2", next.getValue("array.a"));
   }
+
+  @Test
+  public void testConvertCollectionToString() {
+    // json convert inner collections
+    // {
+    //   "array":[
+    //      {
+    //         "array1":[
+    //            {
+    //               "b":"v1"
+    //            }
+    //         ]
+    //      }
+    //   ]
+    // }
+    // is converted to
+    // [{
+    //   "array.array1":"[
+    //            {
+    //               "b":"v1"
+    //            }
+    //         ]"
+    // }]
+    ComplexTypeTransformer transformer = new ComplexTypeTransformer(Arrays.asList("array"), ".");
+    GenericRow genericRow = new GenericRow();
+    Map<String, Object> map = new HashMap<>();
+    Object[] array1 = new Object[1];
+    array1[0] = ImmutableMap.of("b", "v1");
+    map.put("array1", array1);
+    Object[] array = new Object[1];
+    array[0] = map;
+    genericRow.putValue("array", array);
+    transformer.transform(genericRow);
+    Assert.assertNotNull(genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY));
+    Collection<GenericRow> collection = (Collection<GenericRow>) genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY);
+    GenericRow row = collection.iterator().next();
+    Assert.assertTrue(row.getValue("array.array1") instanceof String);
+
+    // primitive array not converted

Review comment:
       The rules aren't clear. As per the design doc (in the Collection handling section), if collection unnesting rule is not applied on a collection, then it will use JSON serialization rule right?
   So why are we differentiating now on primitive collection v/s collection of non scalars ? 




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org