File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
main/java/org/apache/hudi/common/schema
test/java/org/apache/hudi/common/schema Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -723,14 +723,14 @@ public boolean isNullable() {
723723 }
724724
725725 /**
726- * If this is a union schema, returns the non-null type.
726+ * If this is a union schema, returns the non-null type. Otherwise, returns this schema.
727727 *
728- * @return the non-null schema from a union
729- * @throws IllegalStateException if this is not a nullable union
728+ * @return the non-null schema from a union or the current schema
729+ * @throws IllegalStateException if the union has more than two types
730730 */
731731 public HoodieSchema getNonNullType () {
732732 if (type != HoodieSchemaType .UNION ) {
733- throw new IllegalStateException ( "Cannot get non-null type from non-union schema: " + type ) ;
733+ return this ;
734734 }
735735
736736 List <HoodieSchema > types = getTypes ();
Original file line number Diff line number Diff line change @@ -317,9 +317,7 @@ public void testUnionSchemaTypeAccess() {
317317 stringSchema .getTypes ();
318318 }, "Should throw exception when getting types from non-union schema" );
319319
320- assertThrows (IllegalStateException .class , () -> {
321- stringSchema .getNonNullType ();
322- }, "Should throw exception when getting non-null type from non-union schema" );
320+ assertSame (stringSchema , stringSchema .getNonNullType ());
323321 }
324322
325323 @ Test
You can’t perform that action at this time.
0 commit comments