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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6ee657b18e [iceberg] Fix UnsupportedOperationException reading tinyint 
and smallint columns (#7767)
6ee657b18e is described below

commit 6ee657b18eec05fba9744df11f184bbcf979b812
Author: Arnav Balyan <[email protected]>
AuthorDate: Thu May 7 15:36:34 2026 +0530

    [iceberg] Fix UnsupportedOperationException reading tinyint and smallint 
columns (#7767)
    
    - Iceberg toByteBuffer encodes tiny and small int as 4 byte little
    endian int, but IcebergConversions.toPaimonObject has no matching case
    and throws UnsupportedOperationException.
    - Occurs when the type is used as a partition column and decoded back
    into Paimon objects.
---
 .../iceberg/manifest/IcebergConversions.java       |  4 ++
 .../manifest/IcebergConversionsIntegerTest.java    | 62 ++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/iceberg/manifest/IcebergConversions.java
 
b/paimon-core/src/main/java/org/apache/paimon/iceberg/manifest/IcebergConversions.java
index c5bdaf4420..02c1ab8368 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/iceberg/manifest/IcebergConversions.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/iceberg/manifest/IcebergConversions.java
@@ -150,6 +150,10 @@ public class IcebergConversions {
             case INTEGER:
             case DATE:
                 return 
ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
+            case TINYINT:
+                return (byte) 
ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
+            case SMALLINT:
+                return (short) 
ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
             case BIGINT:
                 return 
ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getLong();
             case FLOAT:
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/iceberg/manifest/IcebergConversionsIntegerTest.java
 
b/paimon-core/src/test/java/org/apache/paimon/iceberg/manifest/IcebergConversionsIntegerTest.java
new file mode 100644
index 0000000000..43edb29f8c
--- /dev/null
+++ 
b/paimon-core/src/test/java/org/apache/paimon/iceberg/manifest/IcebergConversionsIntegerTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.iceberg.manifest;
+
+import org.apache.paimon.types.DataTypes;
+
+import org.junit.jupiter.api.Test;
+
+import java.nio.ByteBuffer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class IcebergConversionsIntegerTest {
+
+    @Test
+    void testTinyIntRoundTrip() {
+        byte value = (byte) 42;
+        ByteBuffer buffer = 
IcebergConversions.toByteBuffer(DataTypes.TINYINT(), value);
+        Object decoded = 
IcebergConversions.toPaimonObject(DataTypes.TINYINT(), buffer.array());
+        assertThat(decoded).isEqualTo(value);
+    }
+
+    @Test
+    void testTinyIntRoundTripNegative() {
+        byte value = (byte) -7;
+        ByteBuffer buffer = 
IcebergConversions.toByteBuffer(DataTypes.TINYINT(), value);
+        Object decoded = 
IcebergConversions.toPaimonObject(DataTypes.TINYINT(), buffer.array());
+        assertThat(decoded).isEqualTo(value);
+    }
+
+    @Test
+    void testSmallIntRoundTrip() {
+        short value = (short) 12345;
+        ByteBuffer buffer = 
IcebergConversions.toByteBuffer(DataTypes.SMALLINT(), value);
+        Object decoded = 
IcebergConversions.toPaimonObject(DataTypes.SMALLINT(), buffer.array());
+        assertThat(decoded).isEqualTo(value);
+    }
+
+    @Test
+    void testSmallIntRoundTripNegative() {
+        short value = (short) -1234;
+        ByteBuffer buffer = 
IcebergConversions.toByteBuffer(DataTypes.SMALLINT(), value);
+        Object decoded = 
IcebergConversions.toPaimonObject(DataTypes.SMALLINT(), buffer.array());
+        assertThat(decoded).isEqualTo(value);
+    }
+}

Reply via email to