This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 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 3154fc7f44 [core] Fix the potential NPE in HiveTableUtils (#5133)
3154fc7f44 is described below
commit 3154fc7f445355cb2b20464e35663ad72a0b3cfb
Author: Zouxxyy <[email protected]>
AuthorDate: Sat Feb 22 11:46:58 2025 +0800
[core] Fix the potential NPE in HiveTableUtils (#5133)
---
.../java/org/apache/paimon/hive/HiveTableUtils.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveTableUtils.java
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveTableUtils.java
index 2a8c8dabf8..fa23563a9b 100644
---
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveTableUtils.java
+++
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveTableUtils.java
@@ -25,6 +25,7 @@ import org.apache.paimon.types.RowType;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
import org.apache.hadoop.hive.metastore.api.Table;
import java.util.ArrayList;
@@ -50,12 +51,22 @@ class HiveTableUtils {
List<String> partitionKeys =
getFieldNames(hiveTable.getPartitionKeys());
RowType rowType = createRowType(hiveTable);
String comment = options.remove(COMMENT_PROP);
- String location = hiveTable.getSd().getLocation();
+ StorageDescriptor sd = hiveTable.getSd();
+ if (sd == null) {
+ throw new UnsupportedOperationException("Unsupported table: " +
hiveTable);
+ }
+ String location = sd.getLocation();
Format format;
- SerDeInfo serdeInfo = hiveTable.getSd().getSerdeInfo();
- String serLib = serdeInfo.getSerializationLib().toLowerCase();
- String inputFormat = hiveTable.getSd().getInputFormat();
+ SerDeInfo serdeInfo = sd.getSerdeInfo();
+ if (serdeInfo == null) {
+ throw new UnsupportedOperationException("Unsupported table: " +
hiveTable);
+ }
+ String serLib =
+ serdeInfo.getSerializationLib() == null
+ ? ""
+ : serdeInfo.getSerializationLib().toLowerCase();
+ String inputFormat = sd.getInputFormat() == null ? "" :
sd.getInputFormat();
if (serLib.contains("parquet")) {
format = Format.PARQUET;
} else if (serLib.contains("orc")) {