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

jark pushed a commit to branch ci-2079
in repository https://gitbox.apache.org/repos/asf/fluss.git

commit dce109c2231a221502f3cea944b0e059fe1aebb1
Author: Jark Wu <[email protected]>
AuthorDate: Tue Dec 23 10:28:08 2025 +0800

    fix failed cases
---
 .../src/main/java/org/apache/fluss/row/BinaryWriter.java   |  2 +-
 .../org/apache/fluss/row/serializer/ArraySerializer.java   | 13 ++++++++++++-
 .../org/apache/fluss/row/serializer/RowSerializer.java     | 14 +++++++++++++-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/fluss-common/src/main/java/org/apache/fluss/row/BinaryWriter.java 
b/fluss-common/src/main/java/org/apache/fluss/row/BinaryWriter.java
index 5c542f92f..9f1a110dc 100644
--- a/fluss-common/src/main/java/org/apache/fluss/row/BinaryWriter.java
+++ b/fluss-common/src/main/java/org/apache/fluss/row/BinaryWriter.java
@@ -114,7 +114,7 @@ public interface BinaryWriter {
      *
      * @param elementType the element type
      */
-    private static BinaryWriter.ValueWriter createNotNullValueWriter(
+    static BinaryWriter.ValueWriter createNotNullValueWriter(
             DataType elementType, @Nullable BinaryRowFormat rowFormat) {
         switch (elementType.getTypeRoot()) {
             case CHAR:
diff --git 
a/fluss-common/src/main/java/org/apache/fluss/row/serializer/ArraySerializer.java
 
b/fluss-common/src/main/java/org/apache/fluss/row/serializer/ArraySerializer.java
index 1b24d6e5c..004a3c6e4 100644
--- 
a/fluss-common/src/main/java/org/apache/fluss/row/serializer/ArraySerializer.java
+++ 
b/fluss-common/src/main/java/org/apache/fluss/row/serializer/ArraySerializer.java
@@ -26,10 +26,15 @@ import org.apache.fluss.row.InternalArray;
 import org.apache.fluss.row.array.AlignedArray;
 import org.apache.fluss.row.array.CompactedArray;
 import org.apache.fluss.row.array.IndexedArray;
+import org.apache.fluss.row.array.PrimitiveBinaryArray;
 import org.apache.fluss.types.DataType;
 
 import java.io.Serializable;
 
+import static org.apache.fluss.row.BinaryRow.BinaryRowFormat.ALIGNED;
+import static org.apache.fluss.row.BinaryRow.BinaryRowFormat.COMPACTED;
+import static org.apache.fluss.row.BinaryRow.BinaryRowFormat.INDEXED;
+
 /** Serializer for {@link InternalArray} to {@link BinaryArray} and {@code 
CompactedArray}. */
 public class ArraySerializer implements Serializable {
     private static final long serialVersionUID = 1L;
@@ -76,7 +81,13 @@ public class ArraySerializer implements Serializable {
 
         public BinaryArray toAlignedArray(InternalArray from) {
             if (from instanceof BinaryArray) {
-                return (BinaryArray) from;
+                if (from instanceof PrimitiveBinaryArray
+                        || rowFormat == INDEXED && from instanceof IndexedArray
+                        || rowFormat == COMPACTED && from instanceof 
CompactedArray
+                        || rowFormat == ALIGNED && from instanceof 
AlignedArray) {
+                    // directly return the original array iff the array is in 
the expected format
+                    return (BinaryArray) from;
+                }
             }
 
             if (from instanceof GenericArray) {
diff --git 
a/fluss-common/src/main/java/org/apache/fluss/row/serializer/RowSerializer.java 
b/fluss-common/src/main/java/org/apache/fluss/row/serializer/RowSerializer.java
index 5e2d02e60..3a6c11dfb 100644
--- 
a/fluss-common/src/main/java/org/apache/fluss/row/serializer/RowSerializer.java
+++ 
b/fluss-common/src/main/java/org/apache/fluss/row/serializer/RowSerializer.java
@@ -20,14 +20,21 @@ package org.apache.fluss.row.serializer;
 import org.apache.fluss.row.BinaryRow;
 import org.apache.fluss.row.BinaryRow.BinaryRowFormat;
 import org.apache.fluss.row.InternalRow;
+import org.apache.fluss.row.aligned.AlignedRow;
+import org.apache.fluss.row.compacted.CompactedRow;
 import org.apache.fluss.row.encode.AlignedRowEncoder;
 import org.apache.fluss.row.encode.CompactedRowEncoder;
 import org.apache.fluss.row.encode.IndexedRowEncoder;
 import org.apache.fluss.row.encode.RowEncoder;
+import org.apache.fluss.row.indexed.IndexedRow;
 import org.apache.fluss.types.DataType;
 
 import java.io.Serializable;
 
+import static org.apache.fluss.row.BinaryRow.BinaryRowFormat.ALIGNED;
+import static org.apache.fluss.row.BinaryRow.BinaryRowFormat.COMPACTED;
+import static org.apache.fluss.row.BinaryRow.BinaryRowFormat.INDEXED;
+
 /** Serializer for {@link InternalRow} to {@link BinaryRow}. */
 public class RowSerializer implements Serializable {
     private static final long serialVersionUID = 1L;
@@ -53,7 +60,12 @@ public class RowSerializer implements Serializable {
      */
     public BinaryRow toBinaryRow(InternalRow from) {
         if (from instanceof BinaryRow) {
-            return (BinaryRow) from;
+            if (format == INDEXED && from instanceof IndexedRow
+                    || format == COMPACTED && from instanceof CompactedRow
+                    || format == ALIGNED && from instanceof AlignedRow) {
+                // directly return the original row iff the row is in the 
expected format
+                return (BinaryRow) from;
+            }
         }
 
         if (serializer == null) {

Reply via email to