From d86cd1b7b2cafade02998c0bca0aa6889b97407c Mon Sep 17 00:00:00 2001 From: wuwenchi Date: Tue, 28 May 2024 22:56:10 +0800 Subject: [PATCH] [bugfix](iceberg)support null values as partition (#35503) #31442 test in #34929 When null value is used as the partition value, BE will return the "null" string, so this string needs to be processed specially. --- .../datasource/iceberg/IcebergTransaction.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java index 2e1ad8ab1e1a2e..5025e0751426d9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java @@ -40,6 +40,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; public class IcebergTransaction implements Transaction { @@ -154,11 +155,22 @@ public CommitTaskData(String path, this.path = path; this.fileSizeInBytes = fileSizeInBytes; this.metrics = metrics; - this.partitionValues = partitionValues; + this.partitionValues = convertPartitionValuesForNull(partitionValues); this.content = content; this.referencedDataFiles = referencedDataFiles; } + private Optional> convertPartitionValuesForNull(Optional> partitionValues) { + if (!partitionValues.isPresent()) { + return partitionValues; + } + List values = partitionValues.get(); + if (!values.contains("null")) { + return partitionValues; + } + return Optional.of(values.stream().map(s -> s.equals("null") ? null : s).collect(Collectors.toList())); + } + public String getPath() { return path; }