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 41ff7d543d [hive] Fix Hive read failure for CHAR/VARCHAR columns 
exceeding Hive length limits (#9075)
41ff7d543d is described below

commit 41ff7d543d66c52e7a2de3d51d8001e902ff8afc
Author: Eunbin Son <[email protected]>
AuthorDate: Thu Aug 6 23:12:56 2026 +0900

    [hive] Fix Hive read failure for CHAR/VARCHAR columns exceeding Hive length 
limits (#9075)
---
 .../PaimonObjectInspectorFactory.java              | 10 ++++--
 .../PaimonObjectInspectorFactoryTest.java          | 39 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git 
a/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactory.java
 
b/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactory.java
index f56a65e0ba..e839fa4c20 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactory.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactory.java
@@ -32,6 +32,8 @@ import org.apache.paimon.types.TimeType;
 import org.apache.paimon.types.VarCharType;
 import org.apache.paimon.types.VectorType;
 
+import org.apache.hadoop.hive.common.type.HiveChar;
+import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
 import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
@@ -65,10 +67,14 @@ public class PaimonObjectInspectorFactory {
                         decimalType.getPrecision(), decimalType.getScale());
             case CHAR:
                 CharType charType = (CharType) logicalType;
-                return new PaimonCharObjectInspector(charType.getLength());
+                if (charType.getLength() > HiveChar.MAX_CHAR_LENGTH) {
+                    return new PaimonStringObjectInspector();
+                } else {
+                    return new PaimonCharObjectInspector(charType.getLength());
+                }
             case VARCHAR:
                 VarCharType varCharType = (VarCharType) logicalType;
-                if (varCharType.getLength() == VarCharType.MAX_LENGTH) {
+                if (varCharType.getLength() > HiveVarchar.MAX_VARCHAR_LENGTH) {
                     return new PaimonStringObjectInspector();
                 } else {
                     return new 
PaimonVarcharObjectInspector(varCharType.getLength());
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactoryTest.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactoryTest.java
index 712382279e..4246e30a8c 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactoryTest.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/objectinspector/PaimonObjectInspectorFactoryTest.java
@@ -21,7 +21,10 @@ package org.apache.paimon.hive.objectinspector;
 import org.apache.paimon.data.BinaryString;
 import org.apache.paimon.data.GenericMap;
 import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.VarCharType;
 
+import org.apache.hadoop.hive.common.type.HiveChar;
+import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.junit.jupiter.api.Test;
@@ -68,4 +71,40 @@ public class PaimonObjectInspectorFactoryTest {
         
assertThat(inspector.getStructFieldRef("tags").getFieldObjectInspector().getTypeName())
                 .isEqualTo("map<string,int>");
     }
+
+    @Test
+    public void testCreateCharVarcharObjectInspectorExceedingHiveLimit() {
+        assertThat(
+                        PaimonObjectInspectorFactory.create(
+                                        
DataTypes.CHAR(HiveChar.MAX_CHAR_LENGTH + 1))
+                                .getTypeName())
+                .isEqualTo("string");
+        assertThat(
+                        PaimonObjectInspectorFactory.create(
+                                        
DataTypes.VARCHAR(HiveVarchar.MAX_VARCHAR_LENGTH + 1))
+                                .getTypeName())
+                .isEqualTo("string");
+        // the reproducing case of issue #1565
+        assertThat(
+                        PaimonObjectInspectorFactory.create(
+                                        
DataTypes.VARCHAR(VarCharType.MAX_LENGTH - 1))
+                                .getTypeName())
+                .isEqualTo("string");
+    }
+
+    @Test
+    public void testCreateCharVarcharObjectInspectorWithinHiveLimit() {
+        assertThat(
+                        PaimonObjectInspectorFactory.create(
+                                        
DataTypes.CHAR(HiveChar.MAX_CHAR_LENGTH))
+                                .getTypeName())
+                .isEqualTo("char(" + HiveChar.MAX_CHAR_LENGTH + ")");
+        assertThat(
+                        PaimonObjectInspectorFactory.create(
+                                        
DataTypes.VARCHAR(HiveVarchar.MAX_VARCHAR_LENGTH))
+                                .getTypeName())
+                .isEqualTo("varchar(" + HiveVarchar.MAX_VARCHAR_LENGTH + ")");
+        
assertThat(PaimonObjectInspectorFactory.create(DataTypes.STRING()).getTypeName())
+                .isEqualTo("string");
+    }
 }

Reply via email to