yupeng9 commented on a change in pull request #6918: URL: https://github.com/apache/incubator-pinot/pull/6918#discussion_r632813364
########## 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: coz Pinot natively support multi-value column. Also, per @Jackie-Jiang's suggestion, I'll add a mode so user can choose JSON serialize all collections or collections of non-primitive values. -- 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