Skip to content

Commit febe6af

Browse files
authored
Allow nullable subfields for OneOfType (#36297)
1 parent 7381121 commit febe6af

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/logicaltypes/OneOfType.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ public static OneOfType create(Field... fields) {
7474

7575
/** Create an {@link OneOfType} logical type. */
7676
public static OneOfType create(List<Field> fields) {
77-
for (Field f : fields) {
78-
checkArgument(!f.getType().getNullable(), "OneOf fields do not support nullable subfields.");
79-
}
8077
return new OneOfType(fields);
8178
}
8279

sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/logicaltypes/LogicalTypesTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package org.apache.beam.sdk.schemas.logicaltypes;
1919

20-
import static org.hamcrest.MatcherAssert.assertThat;
2120
import static org.junit.Assert.assertArrayEquals;
2221
import static org.junit.Assert.assertEquals;
2322
import static org.junit.Assert.assertThrows;
@@ -33,7 +32,6 @@
3332
import org.apache.beam.sdk.schemas.logicaltypes.OneOfType.Value;
3433
import org.apache.beam.sdk.values.Row;
3534
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableMap;
36-
import org.hamcrest.Matchers;
3735
import org.junit.Test;
3836

3937
/** Unit tests for logical types. */
@@ -90,21 +88,6 @@ public void testOneOf() {
9088
assertEquals(stringOneOf, stringOneOf2);
9189
}
9290

93-
@Test
94-
public void testOneOfNullable() {
95-
Exception exception =
96-
assertThrows(
97-
IllegalArgumentException.class,
98-
() -> {
99-
OneOfType.create(
100-
Field.nullable("string", FieldType.STRING), Field.of("int32", FieldType.INT32));
101-
});
102-
103-
assertThat(
104-
exception.getMessage(),
105-
Matchers.containsString("OneOf fields do not support nullable subfields."));
106-
}
107-
10891
@Test
10992
public void testNanosInstant() {
11093
Schema rowSchema = new NanosInstant().getBaseType().getRowSchema();

0 commit comments

Comments
 (0)