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 6208af5b28 Fix #9113 Exception when reading Paimon table via Hive
proxy user in … (#9116)
6208af5b28 is described below
commit 6208af5b28c48be812f1c04bf494f8efb781fb53
Author: zhenye zhang <[email protected]>
AuthorDate: Mon Aug 10 16:43:38 2026 +0800
Fix #9113 Exception when reading Paimon table via Hive proxy user in …
(#9116)
---
.../apache/paimon/hive/PaimonStorageHandler.java | 6 +-
.../apache/paimon/hive/HiveTableSchemaTest.java | 74 ++++++++++++++++++++++
2 files changed, 77 insertions(+), 3 deletions(-)
diff --git
a/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/PaimonStorageHandler.java
b/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/PaimonStorageHandler.java
index 5987fd0c9d..071434ec11 100644
---
a/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/PaimonStorageHandler.java
+++
b/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/PaimonStorageHandler.java
@@ -81,12 +81,12 @@ public class PaimonStorageHandler implements
HiveStoragePredicateHandler, HiveSt
Properties properties = tableDesc.getProperties();
String paimonLocation = LocationKeyExtractor.getPaimonLocation(conf,
properties);
map.put(LocationKeyExtractor.INTERNAL_LOCATION, paimonLocation);
- String dataFieldJsonStr = getDataFieldsJsonStr(properties);
+ String dataFieldJsonStr = getDataFieldsJsonStr(conf, properties);
tableDesc.getProperties().put(PAIMON_TABLE_FIELDS, dataFieldJsonStr);
}
- static String getDataFieldsJsonStr(Properties properties) {
- HiveSchema hiveSchema = HiveSchema.extract(null, properties);
+ static String getDataFieldsJsonStr(Configuration conf, Properties
properties) {
+ HiveSchema hiveSchema = HiveSchema.extract(conf, properties);
return JsonSerdeUtil.toJson(hiveSchema.fields());
}
diff --git
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveTableSchemaTest.java
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveTableSchemaTest.java
index 62e11e6df1..a15360fac7 100644
---
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveTableSchemaTest.java
+++
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveTableSchemaTest.java
@@ -29,6 +29,7 @@ import org.apache.paimon.utils.JsonSerdeUtil;
import
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.junit.jupiter.api.Test;
@@ -427,4 +428,77 @@ public class HiveTableSchemaTest {
HiveSchema newHiveSchema = new HiveSchema(new
RowType(dataFieldsDeserialized));
assertThat(newHiveSchema).usingRecursiveComparison().isEqualTo(hiveSchema);
}
+
+ @Test
+ public void testGetDataFieldsJsonStrWithNullConf() throws Exception {
+ createSchema();
+ Properties properties = createTableWithExistsDDL();
+
+ String jsonStr = PaimonStorageHandler.getDataFieldsJsonStr(null,
properties);
+
+ List<DataField> deserializedFields =
+ JsonSerdeUtil.fromJson(jsonStr, new
TypeReference<List<DataField>>() {});
+ assertThat(deserializedFields).hasSize(3);
+ assertThat(deserializedFields.get(0).name()).isEqualTo("a");
+
assertThat(deserializedFields.get(0).type()).isEqualTo(DataTypes.INT());
+ assertThat(deserializedFields.get(0).description()).isEqualTo("first
comment");
+ assertThat(deserializedFields.get(1).name()).isEqualTo("b");
+
assertThat(deserializedFields.get(1).type()).isEqualTo(DataTypes.STRING());
+ assertThat(deserializedFields.get(1).description()).isEqualTo("second
comment");
+ assertThat(deserializedFields.get(2).name()).isEqualTo("c");
+
assertThat(deserializedFields.get(2).type()).isEqualTo(DataTypes.DECIMAL(5, 3));
+ assertThat(deserializedFields.get(2).description()).isEqualTo("last
comment");
+ }
+
+ @Test
+ public void testGetDataFieldsJsonStrWithConf() throws Exception {
+ createSchema();
+ Properties properties = createTableWithExistsDDL();
+ Configuration conf = new Configuration();
+
+ String jsonStr = PaimonStorageHandler.getDataFieldsJsonStr(conf,
properties);
+
+ List<DataField> deserializedFields =
+ JsonSerdeUtil.fromJson(jsonStr, new
TypeReference<List<DataField>>() {});
+ assertThat(deserializedFields).hasSize(3);
+ assertThat(deserializedFields.get(0).name()).isEqualTo("a");
+
assertThat(deserializedFields.get(0).type()).isEqualTo(DataTypes.INT());
+ assertThat(deserializedFields.get(1).name()).isEqualTo("b");
+
assertThat(deserializedFields.get(1).type()).isEqualTo(DataTypes.STRING());
+ assertThat(deserializedFields.get(2).name()).isEqualTo("c");
+
assertThat(deserializedFields.get(2).type()).isEqualTo(DataTypes.DECIMAL(5, 3));
+ }
+
+ @Test
+ public void testGetDataFieldsJsonStrWithEmptyDDLAndPaimonTable() throws
Exception {
+ createSchema();
+ Properties properties = createTableWithEmptyDDL();
+ Configuration conf = new Configuration();
+
+ String jsonStr = PaimonStorageHandler.getDataFieldsJsonStr(conf,
properties);
+
+ List<DataField> deserializedFields =
+ JsonSerdeUtil.fromJson(jsonStr, new
TypeReference<List<DataField>>() {});
+ HiveSchema reconstructedSchema = new HiveSchema(new
RowType(deserializedFields));
+ HiveSchema originalSchema = HiveSchema.extract(conf, properties);
+
assertThat(reconstructedSchema).usingRecursiveComparison().isEqualTo(originalSchema);
+ }
+
+ @Test
+ public void testGetDataFieldsJsonStrRoundtrip() throws Exception {
+ createSchema();
+ Properties properties = createTableWithExistsDDL();
+ Configuration conf = new Configuration();
+
+ String jsonStr = PaimonStorageHandler.getDataFieldsJsonStr(conf,
properties);
+
+ List<DataField> deserializedFields =
+ JsonSerdeUtil.fromJson(jsonStr, new
TypeReference<List<DataField>>() {});
+ HiveSchema schemaFromJson = new HiveSchema(new
RowType(deserializedFields));
+ HiveSchema schemaDirect = HiveSchema.extract(conf, properties);
+
+
assertThat(schemaFromJson.fieldNames()).isEqualTo(schemaDirect.fieldNames());
+
assertThat(schemaFromJson.fieldTypes()).isEqualTo(schemaDirect.fieldTypes());
+
assertThat(schemaFromJson.fieldComments()).isEqualTo(schemaDirect.fieldComments());
+ }
}