[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.
This commit is contained in:
@ -40,6 +40,7 @@ import java.util.ArrayList;
|
||||
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 class IcebergTransaction implements Transaction {
|
||||
this.path = path;
|
||||
this.fileSizeInBytes = fileSizeInBytes;
|
||||
this.metrics = metrics;
|
||||
this.partitionValues = partitionValues;
|
||||
this.partitionValues = convertPartitionValuesForNull(partitionValues);
|
||||
this.content = content;
|
||||
this.referencedDataFiles = referencedDataFiles;
|
||||
}
|
||||
|
||||
private Optional<List<String>> convertPartitionValuesForNull(Optional<List<String>> partitionValues) {
|
||||
if (!partitionValues.isPresent()) {
|
||||
return partitionValues;
|
||||
}
|
||||
List<String> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user