You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by vt...@apache.org on 2026/04/07 11:45:37 UTC
(beam) 01/01: Fix npe
This is an automated email from the ASF dual-hosted git repository.
vterentev pushed a commit to branch fix-sql
in repository https://gitbox.apache.org/repos/asf/beam.git
commit 951c5f666e49262b7ca994eab055507d73d45d0c
Author: Vitaly Terentyev <vi...@akvelon.com>
AuthorDate: Tue Apr 7 15:45:20 2026 +0400
Fix npe
---
.../java/org/apache/beam/sdk/schemas/Schema.java | 38 +++++++++++++++-------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
index 93dd4e1227e..4756be3cf14 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
@@ -963,24 +963,38 @@ public class Schema implements Serializable {
/** Returns true if two FieldTypes are equal. */
public boolean typesEqual(FieldType other) {
- if (!Objects.equals(getTypeName(), other.getTypeName())) {
+ if (other == null) {
return false;
}
- if (getTypeName().isLogicalType()) {
- if (!other.getTypeName().isLogicalType()) {
+ TypeName typeName = getTypeName();
+ TypeName otherTypeName = other.getTypeName();
+ if (!Objects.equals(typeName, otherTypeName)) {
+ return false;
+ }
+ if (typeName == null) {
+ return false;
+ }
+ if (typeName.isLogicalType()) {
+ if (!otherTypeName.isLogicalType()) {
return false;
}
- if (!Objects.equals(
- getLogicalType().getIdentifier(), other.getLogicalType().getIdentifier())) {
+ LogicalType<?, ?> logicalType = getLogicalType();
+ LogicalType<?, ?> otherLogicalType = other.getLogicalType();
+ if (logicalType == null || otherLogicalType == null) {
+ return false;
+ }
+ if (!Objects.equals(logicalType.getIdentifier(), otherLogicalType.getIdentifier())) {
+ return false;
+ }
+ FieldType argumentType = logicalType.getArgumentType();
+ if (!Objects.equals(argumentType, otherLogicalType.getArgumentType())) {
return false;
}
- if (!getLogicalType().getArgumentType().equals(other.getLogicalType().getArgumentType())) {
+ if (argumentType == null) {
return false;
}
if (!Row.Equals.deepEquals(
- getLogicalType().getArgument(),
- other.getLogicalType().getArgument(),
- getLogicalType().getArgumentType())) {
+ logicalType.getArgument(), otherLogicalType.getArgument(), argumentType)) {
return false;
}
}
@@ -990,17 +1004,17 @@ public class Schema implements Serializable {
if (!Objects.equals(getMetadata(), other.getMetadata())) {
return false;
}
- if (getTypeName().isCollectionType()
+ if (typeName.isCollectionType()
&& !getCollectionElementType().typesEqual(other.getCollectionElementType())) {
return false;
}
- if (getTypeName() == TypeName.MAP
+ if (typeName == TypeName.MAP
&& (!getMapValueType().typesEqual(other.getMapValueType())
|| !getMapKeyType().typesEqual(other.getMapKeyType()))) {
return false;
}
- if (getTypeName() == TypeName.ROW && !getRowSchema().typesEqual(other.getRowSchema())) {
+ if (typeName == TypeName.ROW && !getRowSchema().typesEqual(other.getRowSchema())) {
return false;
}
return true;