This is an automated email from the ASF dual-hosted git repository.
yuqi4733 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new f43b836761 #7705 - [Improvement] Add check for null/empty for
partition field na… (#7714)
f43b836761 is described below
commit f43b836761fc8148b73b142315c467dd1bc19953
Author: Raveendra Pujari <[email protected]>
AuthorDate: Mon Dec 8 05:59:02 2025 -0600
#7705 - [Improvement] Add check for null/empty for partition field na…
(#7714)
### What changes were proposed in this pull request?
This PR adds a validation check for the fieldName argument in the
PartitionUtils.validateFieldExistence method to ensure it is not null,
empty, or blank.
This prevents invalid inputs from causing unexpected behavior later in
the validation logic.
### Why are the changes needed?
Previously, the method assumed fieldName and its first element were
valid, which could result in a NullPointerException or invalid behavior
if passed a null, empty, or whitespace-only value.
Fix: #(issue)
### Does this PR introduce _any_ user-facing change?
No, this is an internal utility method enhancement and does not
introduce any user-facing API or configuration change.
### How was this patch tested?
---------
Co-authored-by: Jerry Shao <[email protected]>
---
common/src/main/java/org/apache/gravitino/dto/rel/PartitionUtils.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/common/src/main/java/org/apache/gravitino/dto/rel/PartitionUtils.java
b/common/src/main/java/org/apache/gravitino/dto/rel/PartitionUtils.java
index a9aa5bf3a9..d965ea6908 100644
--- a/common/src/main/java/org/apache/gravitino/dto/rel/PartitionUtils.java
+++ b/common/src/main/java/org/apache/gravitino/dto/rel/PartitionUtils.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
/** Utility class for partitioning validation. */
public class PartitionUtils {
@@ -39,7 +40,8 @@ public class PartitionUtils {
throws IllegalArgumentException {
Preconditions.checkArgument(ArrayUtils.isNotEmpty(columns), "columns
cannot be null or empty");
Preconditions.checkArgument(
- ArrayUtils.isNotEmpty(fieldName), "fieldName cannot be null or empty");
+ ArrayUtils.isNotEmpty(fieldName) &&
StringUtils.isNotBlank(fieldName[0]),
+ "fieldName cannot be null or empty");
// Check if nested fields are supported (currently not supported)
Preconditions.checkArgument(