This is an automated email from the ASF dual-hosted git repository. wzhou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 112bab64b77d6ed966b1c67bd503ed632da6f208 Author: wzhou-code <[email protected]> AuthorDate: Tue Apr 25 12:24:41 2023 -0700 IMPALA-12099: Catalogd throws NPE when refreshing a partitioned table Impala Catalogd assumes that if a table is partitioned then all CompactionInfoStruct entries should not have null partitionname. This assumption is not true. As according to [1], it is possible for a compaction queue entry for a partitioned table to have null partitionname. This patch handles the null case. Testing: - Ran core test. [1] https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Initiator.java#L345 Change-Id: If37559f3c74ac517d1403ddb82ca28708015d6bf Reviewed-on: http://gerrit.cloudera.org:8080/19804 Reviewed-by: Quanlong Huang <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- .../java/org/apache/impala/compat/MetastoreShim.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fe/src/compat-hive-3/java/org/apache/impala/compat/MetastoreShim.java b/fe/src/compat-hive-3/java/org/apache/impala/compat/MetastoreShim.java index b31897287..e7b075e74 100644 --- a/fe/src/compat-hive-3/java/org/apache/impala/compat/MetastoreShim.java +++ b/fe/src/compat-hive-3/java/org/apache/impala/compat/MetastoreShim.java @@ -690,8 +690,15 @@ public class MetastoreShim extends Hive3MetastoreShimBase { Map<String, Long> partNameToCompactionId = new HashMap<>(); if (hdfsTable.isPartitioned()) { for (CompactionInfoStruct ci : response.getCompactions()) { - partNameToCompactionId.put( - Preconditions.checkNotNull(ci.getPartitionname()), ci.getId()); + // It is possible for a partitioned table to have null partitionname in case of + // an aborted dynamic partition insert. + if (ci.getPartitionname() != null) { + partNameToCompactionId.put(ci.getPartitionname(), ci.getId()); + } else { + LOG.warn( + "Partitioned table {} has null partitionname in CompactionInfoStruct: {}", + hdfsTable.getFullName(), ci.toString()); + } } } else { CompactionInfoStruct ci = Iterables.getOnlyElement(response.getCompactions(), null); @@ -749,8 +756,13 @@ public class MetastoreShim extends Hive3MetastoreShimBase { Map<String, Long> partNameToCompactionId = new HashMap<>(); if (table.isPartitioned()) { for (CompactionInfoStruct ci : response.getCompactions()) { - partNameToCompactionId.put( - Preconditions.checkNotNull(ci.getPartitionname()), ci.getId()); + if (ci.getPartitionname() != null) { + partNameToCompactionId.put(ci.getPartitionname(), ci.getId()); + } else { + LOG.warn( + "Partitioned table {} has null partitionname in CompactionInfoStruct: {}", + tableName, ci.toString()); + } } } else { CompactionInfoStruct ci = Iterables.getOnlyElement(response.getCompactions(),
