3535import static org .apache .beam .sdk .io .common .SchemaAwareJavaBeans .timeContainingToRowFn ;
3636
3737import java .math .BigDecimal ;
38+ import java .util .ArrayList ;
3839import java .util .Arrays ;
3940import java .util .Collections ;
4041import java .util .List ;
5051import org .apache .beam .sdk .io .common .SchemaAwareJavaBeans .SinglyNestedDataTypes ;
5152import org .apache .beam .sdk .io .common .SchemaAwareJavaBeans .TimeContaining ;
5253import org .apache .beam .sdk .values .Row ;
54+ import org .apache .beam .vendor .guava .v32_1_2_jre .com .google .common .collect .Lists ;
5355import org .joda .time .Instant ;
5456
5557/** Shared {@link SchemaAwareJavaBeans} data to be used across various tests. */
@@ -60,6 +62,23 @@ class FileWriteSchemaTransformFormatProviderTestData {
6062 /* Prevent instantiation outside this class. */
6163 private FileWriteSchemaTransformFormatProviderTestData () {}
6264
65+ private static class ListPatcher <T > {
66+ private ArrayList <T > list ;
67+
68+ ListPatcher (List <T > list ) {
69+ this .list = Lists .newArrayList (list );
70+ }
71+
72+ ArrayList <T > get () {
73+ return list ;
74+ }
75+
76+ ListPatcher <T > patch (int index , T value ) {
77+ list .set (index , value );
78+ return this ;
79+ }
80+ }
81+
6382 final List <AllPrimitiveDataTypes > allPrimitiveDataTypesList =
6483 Arrays .asList (
6584 allPrimitiveDataTypes (false , BigDecimal .valueOf (1L ), 1.2345 , 1.2345f , 1 , 1L , "a" ),
@@ -188,11 +207,53 @@ private FileWriteSchemaTransformFormatProviderTestData() {}
188207 Collections .emptyList (),
189208 Collections .emptyList ()));
190209
210+ // TODO(AVRO-4110): remove this workaround when Beam upgraded Avro past 1.12.0
211+ final List <ArrayPrimitiveDataTypes > arrayPrimitiveDataTypesListAvro1120 =
212+ new ListPatcher <>(arrayPrimitiveDataTypesList )
213+ .patch (
214+ 1 ,
215+ arrayPrimitiveDataTypes (
216+ Collections .emptyList (),
217+ Collections .singletonList ((double ) Float .MAX_VALUE ),
218+ Collections .emptyList (),
219+ Collections .emptyList (),
220+ Collections .emptyList (),
221+ Collections .emptyList ()))
222+ .patch (
223+ 6 ,
224+ arrayPrimitiveDataTypes (
225+ Arrays .asList (false , true , false ),
226+ Arrays .asList ((double ) Float .MIN_VALUE , 0.0 , (double ) Float .MAX_VALUE ),
227+ Arrays .asList (Float .MIN_VALUE , 0.0f , Float .MAX_VALUE ),
228+ Arrays .asList (Integer .MIN_VALUE , 0 , Integer .MAX_VALUE ),
229+ Arrays .asList (Long .MIN_VALUE , 0L , Long .MAX_VALUE ),
230+ Arrays .asList (
231+ Stream .generate (() -> "🐤" ).limit (10 ).collect (Collectors .joining ("" )),
232+ Stream .generate (() -> "🐥" ).limit (10 ).collect (Collectors .joining ("" )),
233+ Stream .generate (() -> "🐣" ).limit (10 ).collect (Collectors .joining ("" )))))
234+ .patch (
235+ 7 ,
236+ arrayPrimitiveDataTypes (
237+ Stream .generate (() -> true ).limit (10 ).collect (Collectors .toList ()),
238+ Stream .generate (() -> (double ) Float .MIN_VALUE )
239+ .limit (10 )
240+ .collect (Collectors .toList ()),
241+ Stream .generate (() -> Float .MIN_VALUE ).limit (10 ).collect (Collectors .toList ()),
242+ Stream .generate (() -> Integer .MIN_VALUE ).limit (10 ).collect (Collectors .toList ()),
243+ Stream .generate (() -> Long .MIN_VALUE ).limit (10 ).collect (Collectors .toList ()),
244+ Stream .generate (() -> "🐿" ).limit (10 ).collect (Collectors .toList ())))
245+ .get ();
246+
191247 final List <Row > arrayPrimitiveDataTypesRows =
192248 arrayPrimitiveDataTypesList .stream ()
193249 .map (arrayPrimitiveDataTypesToRowFn ()::apply )
194250 .collect (Collectors .toList ());
195251
252+ final List <Row > arrayPrimitiveDataTypesRowsAvro1120 =
253+ arrayPrimitiveDataTypesListAvro1120 .stream ()
254+ .map (arrayPrimitiveDataTypesToRowFn ()::apply )
255+ .collect (Collectors .toList ());
256+
196257 final List <SinglyNestedDataTypes > singlyNestedDataTypesNoRepeat =
197258 allPrimitiveDataTypesList .stream ()
198259 .map (SchemaAwareJavaBeans ::singlyNestedDataTypes )
0 commit comments