@@ -1273,11 +1273,12 @@ mod test {
12731273 } ;
12741274 use crate :: test_util:: arrow_test_data;
12751275 use crate :: writer:: AvroWriter ;
1276- use arrow:: array:: ArrayDataBuilder ;
12771276 use arrow_array:: builder:: {
1278- ArrayBuilder , BooleanBuilder , Float32Builder , Float64Builder , Int32Builder , Int64Builder ,
1279- ListBuilder , MapBuilder , MapFieldNames , StringBuilder , StructBuilder ,
1277+ ArrayBuilder , BooleanBuilder , Float32Builder , Int32Builder , Int64Builder , ListBuilder ,
1278+ MapBuilder , StringBuilder , StructBuilder ,
12801279 } ;
1280+ #[ cfg( feature = "snappy" ) ]
1281+ use arrow_array:: builder:: { Float64Builder , MapFieldNames } ;
12811282 use arrow_array:: cast:: AsArray ;
12821283 #[ cfg( not( feature = "avro_custom_types" ) ) ]
12831284 use arrow_array:: types:: Int64Type ;
@@ -1288,9 +1289,9 @@ mod test {
12881289 } ;
12891290 use arrow_array:: types:: { Int32Type , IntervalMonthDayNanoType } ;
12901291 use arrow_array:: * ;
1291- use arrow_buffer :: {
1292- Buffer , IntervalMonthDayNano , NullBuffer , OffsetBuffer , ScalarBuffer , i256 ,
1293- } ;
1292+ # [ cfg ( feature = "snappy" ) ]
1293+ use arrow_buffer :: { Buffer , NullBuffer } ;
1294+ use arrow_buffer :: { IntervalMonthDayNano , OffsetBuffer , ScalarBuffer , i256 } ;
12941295 #[ cfg( feature = "avro_custom_types" ) ]
12951296 use arrow_schema:: {
12961297 ArrowError , DataType , Field , FieldRef , Fields , IntervalUnit , Schema , TimeUnit , UnionFields ,
@@ -1309,6 +1310,23 @@ mod test {
13091310 use std:: io:: { BufReader , Cursor } ;
13101311 use std:: sync:: Arc ;
13111312
1313+ fn files ( ) -> impl Iterator < Item = & ' static str > {
1314+ [
1315+ // TODO: avoid requiring snappy for this file
1316+ #[ cfg( feature = "snappy" ) ]
1317+ "avro/alltypes_plain.avro" ,
1318+ #[ cfg( feature = "snappy" ) ]
1319+ "avro/alltypes_plain.snappy.avro" ,
1320+ #[ cfg( feature = "zstd" ) ]
1321+ "avro/alltypes_plain.zstandard.avro" ,
1322+ #[ cfg( feature = "bzip2" ) ]
1323+ "avro/alltypes_plain.bzip2.avro" ,
1324+ #[ cfg( feature = "xz" ) ]
1325+ "avro/alltypes_plain.xz.avro" ,
1326+ ]
1327+ . into_iter ( )
1328+ }
1329+
13121330 fn read_file ( path : & str , batch_size : usize , utf8_view : bool ) -> RecordBatch {
13131331 let file = File :: open ( path) . unwrap ( ) ;
13141332 let reader = ReaderBuilder :: new ( )
@@ -1714,14 +1732,7 @@ mod test {
17141732
17151733 #[ test]
17161734 fn test_alltypes_schema_promotion_mixed ( ) {
1717- let files = [
1718- "avro/alltypes_plain.avro" ,
1719- "avro/alltypes_plain.snappy.avro" ,
1720- "avro/alltypes_plain.zstandard.avro" ,
1721- "avro/alltypes_plain.bzip2.avro" ,
1722- "avro/alltypes_plain.xz.avro" ,
1723- ] ;
1724- for file in files {
1735+ for file in files ( ) {
17251736 let file = arrow_test_data ( file) ;
17261737 let mut promotions: HashMap < & str , & str > = HashMap :: new ( ) ;
17271738 promotions. insert ( "id" , "long" ) ;
@@ -1829,14 +1840,7 @@ mod test {
18291840
18301841 #[ test]
18311842 fn test_alltypes_schema_promotion_long_to_float_only ( ) {
1832- let files = [
1833- "avro/alltypes_plain.avro" ,
1834- "avro/alltypes_plain.snappy.avro" ,
1835- "avro/alltypes_plain.zstandard.avro" ,
1836- "avro/alltypes_plain.bzip2.avro" ,
1837- "avro/alltypes_plain.xz.avro" ,
1838- ] ;
1839- for file in files {
1843+ for file in files ( ) {
18401844 let file = arrow_test_data ( file) ;
18411845 let mut promotions: HashMap < & str , & str > = HashMap :: new ( ) ;
18421846 promotions. insert ( "bigint_col" , "float" ) ;
@@ -1933,14 +1937,7 @@ mod test {
19331937
19341938 #[ test]
19351939 fn test_alltypes_schema_promotion_bytes_to_string_only ( ) {
1936- let files = [
1937- "avro/alltypes_plain.avro" ,
1938- "avro/alltypes_plain.snappy.avro" ,
1939- "avro/alltypes_plain.zstandard.avro" ,
1940- "avro/alltypes_plain.bzip2.avro" ,
1941- "avro/alltypes_plain.xz.avro" ,
1942- ] ;
1943- for file in files {
1940+ for file in files ( ) {
19441941 let file = arrow_test_data ( file) ;
19451942 let mut promotions: HashMap < & str , & str > = HashMap :: new ( ) ;
19461943 promotions. insert ( "date_string_col" , "string" ) ;
@@ -2033,6 +2030,8 @@ mod test {
20332030 }
20342031
20352032 #[ test]
2033+ // TODO: avoid requiring snappy for this file
2034+ #[ cfg( feature = "snappy" ) ]
20362035 fn test_alltypes_illegal_promotion_bool_to_double_errors ( ) {
20372036 let file = arrow_test_data ( "avro/alltypes_plain.avro" ) ;
20382037 let mut promotions: HashMap < & str , & str > = HashMap :: new ( ) ;
@@ -2691,6 +2690,8 @@ mod test {
26912690 }
26922691
26932692 #[ test]
2693+ // TODO: avoid requiring snappy for this file
2694+ #[ cfg( feature = "snappy" ) ]
26942695 fn test_alltypes_skip_writer_fields_keep_double_only ( ) {
26952696 let file = arrow_test_data ( "avro/alltypes_plain.avro" ) ;
26962697 let reader_schema =
@@ -2708,6 +2709,8 @@ mod test {
27082709 }
27092710
27102711 #[ test]
2712+ // TODO: avoid requiring snappy for this file
2713+ #[ cfg( feature = "snappy" ) ]
27112714 fn test_alltypes_skip_writer_fields_reorder_and_skip_many ( ) {
27122715 let file = arrow_test_data ( "avro/alltypes_plain.avro" ) ;
27132716 let reader_schema =
@@ -4470,14 +4473,6 @@ mod test {
44704473
44714474 #[ test]
44724475 fn test_alltypes ( ) {
4473- let files = [
4474- "avro/alltypes_plain.avro" ,
4475- "avro/alltypes_plain.snappy.avro" ,
4476- "avro/alltypes_plain.zstandard.avro" ,
4477- "avro/alltypes_plain.bzip2.avro" ,
4478- "avro/alltypes_plain.xz.avro" ,
4479- ] ;
4480-
44814476 let expected = RecordBatch :: try_from_iter_with_nullable ( [
44824477 (
44834478 "id" ,
@@ -4562,7 +4557,7 @@ mod test {
45624557 ] )
45634558 . unwrap ( ) ;
45644559
4565- for file in files {
4560+ for file in files ( ) {
45664561 let file = arrow_test_data ( file) ;
45674562
45684563 assert_eq ! ( read_file( & file, 8 , false ) , expected) ;
@@ -4571,6 +4566,8 @@ mod test {
45714566 }
45724567
45734568 #[ test]
4569+ // TODO: avoid requiring snappy for this file
4570+ #[ cfg( feature = "snappy" ) ]
45744571 fn test_alltypes_dictionary ( ) {
45754572 let file = "avro/alltypes_dictionary.avro" ;
45764573 let expected = RecordBatch :: try_from_iter_with_nullable ( [
@@ -4693,6 +4690,8 @@ mod test {
46934690 }
46944691
46954692 #[ test]
4693+ // TODO: avoid requiring snappy for this file
4694+ #[ cfg( feature = "snappy" ) ]
46964695 fn test_binary ( ) {
46974696 let file = arrow_test_data ( "avro/binary.avro" ) ;
46984697 let batch = read_file ( & file, 8 , false ) ;
@@ -4719,6 +4718,8 @@ mod test {
47194718 }
47204719
47214720 #[ test]
4721+ // TODO: avoid requiring snappy for these files
4722+ #[ cfg( feature = "snappy" ) ]
47224723 fn test_decimal ( ) {
47234724 // Choose expected Arrow types depending on the `small_decimals` feature flag.
47244725 // With `small_decimals` enabled, Decimal32/Decimal64 are used where their
@@ -5040,6 +5041,8 @@ mod test {
50405041 }
50415042
50425043 #[ test]
5044+ // TODO: avoid requiring snappy for this file
5045+ #[ cfg( feature = "snappy" ) ]
50435046 fn test_dict_pages_offset_zero ( ) {
50445047 let file = arrow_test_data ( "avro/dict-page-offset-zero.avro" ) ;
50455048 let batch = read_file ( & file, 32 , false ) ;
@@ -5055,6 +5058,8 @@ mod test {
50555058 }
50565059
50575060 #[ test]
5061+ // TODO: avoid requiring snappy for this file
5062+ #[ cfg( feature = "snappy" ) ]
50585063 fn test_list_columns ( ) {
50595064 let file = arrow_test_data ( "avro/list_columns.avro" ) ;
50605065 let mut int64_list_builder = ListBuilder :: new ( Int64Builder :: new ( ) ) ;
@@ -5117,6 +5122,7 @@ mod test {
51175122 }
51185123
51195124 #[ test]
5125+ #[ cfg( feature = "snappy" ) ]
51205126 fn test_nested_lists ( ) {
51215127 use arrow_data:: ArrayDataBuilder ;
51225128 let file = arrow_test_data ( "avro/nested_lists.snappy.avro" ) ;
@@ -5314,6 +5320,7 @@ mod test {
53145320 }
53155321
53165322 #[ test]
5323+ #[ cfg( feature = "snappy" ) ]
53175324 fn test_single_nan ( ) {
53185325 let file = arrow_test_data ( "avro/single_nan.avro" ) ;
53195326 let actual = read_file ( & file, 1 , false ) ;
@@ -5392,6 +5399,7 @@ mod test {
53925399 }
53935400
53945401 #[ test]
5402+ #[ cfg( feature = "snappy" ) ]
53955403 fn test_datapage_v2 ( ) {
53965404 let file = arrow_test_data ( "avro/datapage_v2.snappy.avro" ) ;
53975405 let batch = read_file ( & file, 8 , false ) ;
@@ -5653,7 +5661,10 @@ mod test {
56535661 }
56545662
56555663 #[ test]
5664+ // TODO: avoid requiring snappy for this file
5665+ #[ cfg( feature = "snappy" ) ]
56565666 fn test_repeated_no_annotation ( ) {
5667+ use arrow_data:: ArrayDataBuilder ;
56575668 let file = arrow_test_data ( "avro/repeated_no_annotation.avro" ) ;
56585669 let batch_large = read_file ( & file, 8 , false ) ;
56595670 // id column
@@ -5742,6 +5753,8 @@ mod test {
57425753 }
57435754
57445755 #[ test]
5756+ // TODO: avoid requiring snappy for this file
5757+ #[ cfg( feature = "snappy" ) ]
57455758 fn test_nonnullable_impala ( ) {
57465759 let file = arrow_test_data ( "avro/nonnullable.impala.avro" ) ;
57475760 let id = Int64Array :: from ( vec ! [ Some ( 8 ) ] ) ;
@@ -6057,6 +6070,8 @@ mod test {
60576070 }
60586071
60596072 #[ test]
6073+ // TODO: avoid requiring snappy for this file
6074+ #[ cfg( feature = "snappy" ) ]
60606075 fn test_nullable_impala ( ) {
60616076 let file = arrow_test_data ( "avro/nullable.impala.avro" ) ;
60626077 let batch1 = read_file ( & file, 3 , false ) ;
0 commit comments