@@ -1338,3 +1338,79 @@ def test_record_batch_file_writer_with_empty_metadata():
1338
1338
buffer = sink .getvalue ()
1339
1339
with pa .ipc .open_file (buffer ) as r :
1340
1340
assert r .metadata is None
1341
+
1342
+
1343
+ def check_ipc_options_repr (options_obj , options_args ):
1344
+ options = options_obj (** options_args )
1345
+ repr = options .__repr__ ()
1346
+
1347
+ for arg , val in options_args .items ():
1348
+ if val is None :
1349
+ continue
1350
+
1351
+ value = val if not isinstance (val , str ) else f"\" { val } \" "
1352
+
1353
+ if arg == "ensure_alignment" :
1354
+ value = pa .ipc .Alignment (val ).name
1355
+ elif arg == "metadata_version" :
1356
+ value = pa .ipc .MetadataVersion (val ).name
1357
+
1358
+ assert f"{ arg } ={ value } " in repr
1359
+
1360
+
1361
+ @pytest .fixture
1362
+ def write_options_args (request ):
1363
+ match request .param :
1364
+ case "default" :
1365
+ return {
1366
+ "allow_64bit" : False ,
1367
+ "use_legacy_format" : False ,
1368
+ "metadata_version" : pa .ipc .MetadataVersion .V5 ,
1369
+ "compression" : None ,
1370
+ "use_threads" : True ,
1371
+ "emit_dictionary_deltas" : False ,
1372
+ "unify_dictionaries" : False ,
1373
+ }
1374
+ case "all" :
1375
+ return {
1376
+ "allow_64bit" : True ,
1377
+ "use_legacy_format" : True ,
1378
+ "metadata_version" : pa .ipc .MetadataVersion .V4 ,
1379
+ "compression" : "zstd" ,
1380
+ "use_threads" : False ,
1381
+ "emit_dictionary_deltas" : True ,
1382
+ "unify_dictionaries" : True ,
1383
+ }
1384
+
1385
+
1386
+ @pytest .mark .parametrize (
1387
+ "write_options_args" , ["default" , "all" ], indirect = True )
1388
+ def test_write_options_repr (write_options_args ):
1389
+ # https://github.com/apache/arrow/issues/47358
1390
+ check_ipc_options_repr (pa .ipc .IpcWriteOptions , write_options_args )
1391
+
1392
+
1393
+ @pytest .fixture
1394
+ def read_options_args (request ):
1395
+ match request .param :
1396
+ case "default" :
1397
+ return {
1398
+ "ensure_native_endian" : True ,
1399
+ "ensure_alignment" : pa .ipc .Alignment .Any ,
1400
+ "use_threads" : True ,
1401
+ "included_fields" : None ,
1402
+ }
1403
+ case "all" :
1404
+ return {
1405
+ "ensure_native_endian" : False ,
1406
+ "ensure_alignment" : pa .ipc .Alignment .DataTypeSpecific ,
1407
+ "use_threads" : False ,
1408
+ "included_fields" : [1 , 2 , 3 ],
1409
+ }
1410
+
1411
+
1412
+ @pytest .mark .parametrize (
1413
+ "read_options_args" , ["default" , "all" ], indirect = True )
1414
+ def test_read_options_repr (read_options_args ):
1415
+ # https://github.com/apache/arrow/issues/47358
1416
+ check_ipc_options_repr (pa .ipc .IpcReadOptions , read_options_args )
0 commit comments