yupeng9 commented on a change in pull request #6918: URL: https://github.com/apache/incubator-pinot/pull/6918#discussion_r632867121
########## 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: I see. The disconnect here is that there is no nested collection. All nested collection will be flattened to become top-level, and we have two choices on them: collections of pritimive values stay the same while collections of non-primitives convert to String -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org