binary-signal commented on code in PR #2166:
URL: https://github.com/apache/fluss/pull/2166#discussion_r2622087438


##########
fluss-lake/fluss-lake-paimon/src/test/java/org/apache/fluss/lake/paimon/source/FlussRowAsPaimonRowTest.java:
##########
@@ -140,4 +142,346 @@ void testPrimaryKeyTableRecord() {
         assertThat(new FlussRowAsPaimonRow(logRecord.getRow(), 
tableRowType).getRowKind())
                 .isEqualTo(RowKind.INSERT);
     }
+
+    @Test
+    void testArrayTypeWithIntElements() {
+        RowType tableRowType =
+                RowType.of(
+                        new org.apache.paimon.types.IntType(),
+                        new org.apache.paimon.types.ArrayType(
+                                new org.apache.paimon.types.IntType()));
+
+        long logOffset = 0;
+        long timeStamp = System.currentTimeMillis();
+        GenericRow genericRow = new GenericRow(2);
+        genericRow.setField(0, 42);
+        genericRow.setField(1, new GenericArray(new int[] {1, 2, 3, 4, 5}));
+
+        LogRecord logRecord = new GenericRecord(logOffset, timeStamp, 
APPEND_ONLY, genericRow);
+        FlussRowAsPaimonRow flussRowAsPaimonRow =
+                new FlussRowAsPaimonRow(logRecord.getRow(), tableRowType);
+
+        assertThat(flussRowAsPaimonRow.getInt(0)).isEqualTo(42);
+        InternalArray array = flussRowAsPaimonRow.getArray(1);
+        assertThat(array).isNotNull();
+        assertThat(array.size()).isEqualTo(5);
+        assertThat(array.getInt(0)).isEqualTo(1);
+        assertThat(array.getInt(1)).isEqualTo(2);
+        assertThat(array.getInt(2)).isEqualTo(3);
+        assertThat(array.getInt(3)).isEqualTo(4);
+        assertThat(array.getInt(4)).isEqualTo(5);
+    }
+
+    @Test
+    void testArrayTypeWithStringElements() {
+        RowType tableRowType =
+                RowType.of(
+                        new org.apache.paimon.types.VarCharType(),
+                        new org.apache.paimon.types.ArrayType(
+                                new org.apache.paimon.types.VarCharType()));
+
+        long logOffset = 0;
+        long timeStamp = System.currentTimeMillis();
+        GenericRow genericRow = new GenericRow(2);
+        genericRow.setField(0, BinaryString.fromString("name"));
+        genericRow.setField(
+                1,
+                new GenericArray(
+                        new Object[] {
+                            BinaryString.fromString("a"),
+                            BinaryString.fromString("b"),
+                            BinaryString.fromString("c")
+                        }));
+
+        LogRecord logRecord = new GenericRecord(logOffset, timeStamp, 
APPEND_ONLY, genericRow);
+        FlussRowAsPaimonRow flussRowAsPaimonRow =
+                new FlussRowAsPaimonRow(logRecord.getRow(), tableRowType);
+
+        
assertThat(flussRowAsPaimonRow.getString(0).toString()).isEqualTo("name");
+        InternalArray array = flussRowAsPaimonRow.getArray(1);
+        assertThat(array).isNotNull();
+        assertThat(array.size()).isEqualTo(3);
+        assertThat(array.getString(0).toString()).isEqualTo("a");
+        assertThat(array.getString(1).toString()).isEqualTo("b");
+        assertThat(array.getString(2).toString()).isEqualTo("c");
+    }
+
+    @Test
+    void testArrayTypeWithNullableElements() {
+        RowType tableRowType =
+                RowType.of(
+                        new org.apache.paimon.types.ArrayType(
+                                new 
org.apache.paimon.types.IntType().nullable()));
+
+        long logOffset = 0;
+        long timeStamp = System.currentTimeMillis();
+        GenericRow genericRow = new GenericRow(1);
+        genericRow.setField(0, new GenericArray(new Object[] {1, null, 3}));
+
+        LogRecord logRecord = new GenericRecord(logOffset, timeStamp, 
APPEND_ONLY, genericRow);
+        FlussRowAsPaimonRow flussRowAsPaimonRow =
+                new FlussRowAsPaimonRow(logRecord.getRow(), tableRowType);
+
+        InternalArray array = flussRowAsPaimonRow.getArray(0);
+        assertThat(array).isNotNull();
+        assertThat(array.size()).isEqualTo(3);
+        assertThat(array.getInt(0)).isEqualTo(1);
+        assertThat(array.isNullAt(1)).isTrue();
+        assertThat(array.getInt(2)).isEqualTo(3);
+    }
+
+    @Test
+    void testNullArray() {
+        RowType tableRowType =
+                RowType.of(
+                        new org.apache.paimon.types.ArrayType(new 
org.apache.paimon.types.IntType())
+                                .nullable());
+
+        long logOffset = 0;
+        long timeStamp = System.currentTimeMillis();
+        GenericRow genericRow = new GenericRow(1);
+        genericRow.setField(0, null);
+
+        LogRecord logRecord = new GenericRecord(logOffset, timeStamp, 
APPEND_ONLY, genericRow);
+        FlussRowAsPaimonRow flussRowAsPaimonRow =
+                new FlussRowAsPaimonRow(logRecord.getRow(), tableRowType);
+
+        assertThat(flussRowAsPaimonRow.isNullAt(0)).isTrue();
+    }
+
+    @Test
+    void testNestedArrayType() {
+        // Test ARRAY<ARRAY<INT>>
+        RowType tableRowType =
+                RowType.of(
+                        new org.apache.paimon.types.ArrayType(
+                                new org.apache.paimon.types.ArrayType(
+                                        new 
org.apache.paimon.types.IntType())));
+
+        long logOffset = 0;
+        long timeStamp = System.currentTimeMillis();
+        GenericRow genericRow = new GenericRow(1);
+        genericRow.setField(
+                0,
+                new GenericArray(
+                        new Object[] {
+                            new GenericArray(new int[] {1, 2}),
+                            new GenericArray(new int[] {3, 4, 5})
+                        }));
+
+        LogRecord logRecord = new GenericRecord(logOffset, timeStamp, 
APPEND_ONLY, genericRow);
+        FlussRowAsPaimonRow flussRowAsPaimonRow =
+                new FlussRowAsPaimonRow(logRecord.getRow(), tableRowType);
+
+        InternalArray outerArray = flussRowAsPaimonRow.getArray(0);
+        assertThat(outerArray).isNotNull();
+        assertThat(outerArray.size()).isEqualTo(2);
+
+        InternalArray innerArray1 = outerArray.getArray(0);
+        assertThat(innerArray1.size()).isEqualTo(2);
+        assertThat(innerArray1.getInt(0)).isEqualTo(1);
+        assertThat(innerArray1.getInt(1)).isEqualTo(2);
+
+        InternalArray innerArray2 = outerArray.getArray(1);
+        assertThat(innerArray2.size()).isEqualTo(3);
+        assertThat(innerArray2.getInt(0)).isEqualTo(3);
+        assertThat(innerArray2.getInt(1)).isEqualTo(4);
+        assertThat(innerArray2.getInt(2)).isEqualTo(5);
+    }
+
+    @Test
+    void testEmptyArray() {
+        RowType tableRowType =
+                RowType.of(
+                        new org.apache.paimon.types.ArrayType(
+                                new org.apache.paimon.types.IntType()));
+
+        long logOffset = 0;
+        long timeStamp = System.currentTimeMillis();
+        GenericRow genericRow = new GenericRow(1);
+        genericRow.setField(0, new GenericArray(new int[] {}));
+
+        LogRecord logRecord = new GenericRecord(logOffset, timeStamp, 
APPEND_ONLY, genericRow);
+        FlussRowAsPaimonRow flussRowAsPaimonRow =
+                new FlussRowAsPaimonRow(logRecord.getRow(), tableRowType);
+
+        InternalArray array = flussRowAsPaimonRow.getArray(0);
+        assertThat(array).isNotNull();
+        assertThat(array.size()).isEqualTo(0);
+    }
+
+    @Test
+    void testArrayWithAllPrimitiveTypes() {

Review Comment:
   Yes that make sense I am on it 



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