MashrafeeAryan commented on code in PR #52580: URL: https://github.com/apache/arrow/pull/52580#discussion_r4381934105
########## python/pyarrow/tests/parquet/test_parquet_writer.py: ########## @@ -41,6 +43,106 @@ pytestmark = pytest.mark.parquet [email protected]("page_version, minimum", [ + ("1.0", None), + ("2.0", None), + ("2.0", 0.0), + ("2.0", 0.1), + ("2.0", 1.0), +]) [email protected]("compression", ["none", "snappy"]) [email protected]("use_writer", [False, True]) +def test_min_space_savings( + minimum, page_version, compression, use_writer): + table = pa.table({ + "value": pa.array([0.0] * 1000, type=pa.float32()) + }) + sink = pa.BufferOutputStream() + options = dict( + compression=compression, + use_dictionary=False, + data_page_version=page_version, + min_space_savings=minimum, + ) + + if use_writer: + with pq.ParquetWriter(sink, table.schema, **options) as writer: + writer.write_table(table) + else: + pq.write_table(table, sink, **options) + + buf = sink.getvalue() + assert pq.read_table(buf).equals(table) + + column = pq.ParquetFile(buf).metadata.row_group(0).column(0) + expect_uncompressed = ( + compression == "none" + or (page_version == "2.0" and minimum == 1.0) + ) + if expect_uncompressed: + assert column.total_compressed_size == column.total_uncompressed_size + else: + assert column.total_compressed_size < column.total_uncompressed_size + + +def _v2_column_chunk(table, **options): Review Comment: I agree with you. I have updated those tests accordingly -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
