-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Mitigate test broken after Avro Upgrade due to AVRO-4110 #38405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import static org.apache.beam.sdk.io.common.SchemaAwareJavaBeans.timeContainingToRowFn; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
@@ -50,6 +51,7 @@ | |
| import org.apache.beam.sdk.io.common.SchemaAwareJavaBeans.SinglyNestedDataTypes; | ||
| import org.apache.beam.sdk.io.common.SchemaAwareJavaBeans.TimeContaining; | ||
| import org.apache.beam.sdk.values.Row; | ||
| import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.Lists; | ||
| import org.joda.time.Instant; | ||
|
|
||
| /** Shared {@link SchemaAwareJavaBeans} data to be used across various tests. */ | ||
|
|
@@ -60,6 +62,23 @@ class FileWriteSchemaTransformFormatProviderTestData { | |
| /* Prevent instantiation outside this class. */ | ||
| private FileWriteSchemaTransformFormatProviderTestData() {} | ||
|
|
||
| private static class ListPatcher<T> { | ||
| private ArrayList<T> list; | ||
|
|
||
| ListPatcher(List<T> list) { | ||
| this.list = Lists.newArrayList(list); | ||
| } | ||
|
|
||
| ArrayList<T> get() { | ||
| return list; | ||
| } | ||
|
|
||
| ListPatcher<T> patch(int index, T value) { | ||
| list.set(index, value); | ||
| return this; | ||
| } | ||
| } | ||
|
Comment on lines
+65
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The private static class ListPatcher<T> {\n private final List<T> list;\n\n ListPatcher(List<T> list) {\n this.list = new ArrayList<>(list);\n }\n\n List<T> get() {\n return list;\n }\n\n ListPatcher<T> patch(int index, T value) {\n list.set(index, value);\n return this;\n }\n } |
||
|
|
||
| final List<AllPrimitiveDataTypes> allPrimitiveDataTypesList = | ||
| Arrays.asList( | ||
| allPrimitiveDataTypes(false, BigDecimal.valueOf(1L), 1.2345, 1.2345f, 1, 1L, "a"), | ||
|
|
@@ -188,11 +207,53 @@ private FileWriteSchemaTransformFormatProviderTestData() {} | |
| Collections.emptyList(), | ||
| Collections.emptyList())); | ||
|
|
||
| // TODO(AVRO-4110): remove this workaround when Beam upgraded Avro past 1.12.0 | ||
| final List<ArrayPrimitiveDataTypes> arrayPrimitiveDataTypesListAvro1120 = | ||
| new ListPatcher<>(arrayPrimitiveDataTypesList) | ||
| .patch( | ||
| 1, | ||
| arrayPrimitiveDataTypes( | ||
| Collections.emptyList(), | ||
| Collections.singletonList((double) Float.MAX_VALUE), | ||
| Collections.emptyList(), | ||
| Collections.emptyList(), | ||
| Collections.emptyList(), | ||
| Collections.emptyList())) | ||
| .patch( | ||
| 6, | ||
| arrayPrimitiveDataTypes( | ||
| Arrays.asList(false, true, false), | ||
| Arrays.asList((double) Float.MIN_VALUE, 0.0, (double) Float.MAX_VALUE), | ||
| Arrays.asList(Float.MIN_VALUE, 0.0f, Float.MAX_VALUE), | ||
| Arrays.asList(Integer.MIN_VALUE, 0, Integer.MAX_VALUE), | ||
| Arrays.asList(Long.MIN_VALUE, 0L, Long.MAX_VALUE), | ||
| Arrays.asList( | ||
| Stream.generate(() -> "🐤").limit(10).collect(Collectors.joining("")), | ||
| Stream.generate(() -> "🐥").limit(10).collect(Collectors.joining("")), | ||
| Stream.generate(() -> "🐣").limit(10).collect(Collectors.joining(""))))) | ||
| .patch( | ||
| 7, | ||
| arrayPrimitiveDataTypes( | ||
| Stream.generate(() -> true).limit(10).collect(Collectors.toList()), | ||
| Stream.generate(() -> (double) Float.MIN_VALUE) | ||
| .limit(10) | ||
| .collect(Collectors.toList()), | ||
| Stream.generate(() -> Float.MIN_VALUE).limit(10).collect(Collectors.toList()), | ||
| Stream.generate(() -> Integer.MIN_VALUE).limit(10).collect(Collectors.toList()), | ||
| Stream.generate(() -> Long.MIN_VALUE).limit(10).collect(Collectors.toList()), | ||
| Stream.generate(() -> "🐿").limit(10).collect(Collectors.toList()))) | ||
| .get(); | ||
|
|
||
| final List<Row> arrayPrimitiveDataTypesRows = | ||
| arrayPrimitiveDataTypesList.stream() | ||
| .map(arrayPrimitiveDataTypesToRowFn()::apply) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| final List<Row> arrayPrimitiveDataTypesRowsAvro1120 = | ||
| arrayPrimitiveDataTypesListAvro1120.stream() | ||
| .map(arrayPrimitiveDataTypesToRowFn()::apply) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| final List<SinglyNestedDataTypes> singlyNestedDataTypesNoRepeat = | ||
| allPrimitiveDataTypesList.stream() | ||
| .map(SchemaAwareJavaBeans::singlyNestedDataTypes) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is no longer needed if the
ListPatcherclass is refactored to use the standardArrayListconstructor instead of the vendored Guava utility.