This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new ae9bd336ed Add partial unnest array test in ComplexTypeTransformerTest 
(#14333)
ae9bd336ed is described below

commit ae9bd336ed76d8be5fbd8ccb5dc874fe50ecb2d3
Author: Xiang Fu <[email protected]>
AuthorDate: Wed Oct 30 07:33:25 2024 +0800

    Add partial unnest array test in ComplexTypeTransformerTest (#14333)
---
 .../ComplexTypeTransformerTest.java                | 52 ++++++++++++++--------
 1 file changed, 34 insertions(+), 18 deletions(-)

diff --git 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/ComplexTypeTransformerTest.java
 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/ComplexTypeTransformerTest.java
index 81a1c4d3f8..96adcfc8cc 100644
--- 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/ComplexTypeTransformerTest.java
+++ 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/ComplexTypeTransformerTest.java
@@ -128,10 +128,10 @@ public class ComplexTypeTransformerTest {
     transformer.transform(genericRow);
     Assert.assertNotNull(genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY));
     Collection<GenericRow> collection = (Collection<GenericRow>) 
genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY);
-    Assert.assertEquals(2, collection.size());
+    Assert.assertEquals(collection.size(), 2);
     Iterator<GenericRow> itr = collection.iterator();
-    Assert.assertEquals("v1", itr.next().getValue("array.a"));
-    Assert.assertEquals("v2", itr.next().getValue("array.a"));
+    Assert.assertEquals(itr.next().getValue("array.a"), "v1");
+    Assert.assertEquals(itr.next().getValue("array.a"), "v2");
 
     // unnest sibling collections
     //    {
@@ -179,20 +179,20 @@ public class ComplexTypeTransformerTest {
     transformer.transform(genericRow);
     Assert.assertNotNull(genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY));
     collection = (Collection<GenericRow>) 
genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY);
-    Assert.assertEquals(4, collection.size());
+    Assert.assertEquals(collection.size(), 4);
     itr = collection.iterator();
     GenericRow next = itr.next();
-    Assert.assertEquals("v1", next.getValue("array.a"));
-    Assert.assertEquals("v3", next.getValue("array2.b"));
+    Assert.assertEquals(next.getValue("array.a"), "v1");
+    Assert.assertEquals(next.getValue("array2.b"), "v3");
     next = itr.next();
-    Assert.assertEquals("v1", next.getValue("array.a"));
-    Assert.assertEquals("v4", next.getValue("array2.b"));
+    Assert.assertEquals(next.getValue("array.a"), "v1");
+    Assert.assertEquals(next.getValue("array2.b"), "v4");
     next = itr.next();
-    Assert.assertEquals("v2", next.getValue("array.a"));
-    Assert.assertEquals("v3", next.getValue("array2.b"));
+    Assert.assertEquals(next.getValue("array.a"), "v2");
+    Assert.assertEquals(next.getValue("array2.b"), "v3");
     next = itr.next();
-    Assert.assertEquals("v2", next.getValue("array.a"));
-    Assert.assertEquals("v4", next.getValue("array2.b"));
+    Assert.assertEquals(next.getValue("array.a"), "v2");
+    Assert.assertEquals(next.getValue("array2.b"), "v4");
 
     // unnest nested collection
     // {
@@ -234,16 +234,32 @@ public class ComplexTypeTransformerTest {
     transformer.transform(genericRow);
     Assert.assertNotNull(genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY));
     collection = (Collection<GenericRow>) 
genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY);
-    Assert.assertEquals(3, collection.size());
+    Assert.assertEquals(collection.size(), 3);
     itr = collection.iterator();
     next = itr.next();
-    Assert.assertEquals("v1", next.getValue("array.a"));
-    Assert.assertEquals("v3", next.getValue("array.array2.b"));
+    Assert.assertEquals(next.getValue("array.a"), "v1");
+    Assert.assertEquals(next.getValue("array.array2.b"), "v3");
     next = itr.next();
-    Assert.assertEquals("v1", next.getValue("array.a"));
-    Assert.assertEquals("v4", next.getValue("array.array2.b"));
+    Assert.assertEquals(next.getValue("array.a"), "v1");
+    Assert.assertEquals(next.getValue("array.array2.b"), "v4");
     next = itr.next();
-    Assert.assertEquals("v2", next.getValue("array.a"));
+    Assert.assertEquals(next.getValue("array.a"), "v2");
+
+    transformer = new ComplexTypeTransformer(Arrays.asList("array"), ".");
+    genericRow = new GenericRow();
+    genericRow.putValue("array", array);
+    map1.put("array2", array2);
+    map2.put("array2", new Object[]{});
+    transformer.transform(genericRow);
+    Assert.assertNotNull(genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY));
+    collection = (Collection<GenericRow>) 
genericRow.getValue(GenericRow.MULTIPLE_RECORDS_KEY);
+    Assert.assertEquals(collection.size(), 2);
+    itr = collection.iterator();
+    next = itr.next();
+    Assert.assertEquals(next.getValue("array.a"), "v1");
+    Assert.assertEquals(next.getValue("array.array2"), 
"[{\"b\":\"v3\"},{\"b\":\"v4\"}]");
+    next = itr.next();
+    Assert.assertEquals(next.getValue("array.a"), "v2");
   }
 
   @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to