@@ -3045,6 +3045,35 @@ def test_write_file_rejects_timestamptz_to_timestamp(tmp_path: Path) -> None:
30453045 list (write_file (io = PyArrowFileIO (), table_metadata = table_metadata , tasks = iter ([task ])))
30463046
30473047
3048+ def test_write_file_reads_parquet_metadata (tmp_path : Path ) -> None :
3049+ from pyiceberg .table import WriteTask
3050+
3051+ table_schema = Schema (NestedField (1 , "id" , IntegerType (), required = False ))
3052+ arrow_data = pa .table ({"id" : pa .array ([1 , 2 , 3 ], type = pa .int32 ())})
3053+
3054+ table_metadata = TableMetadataV2 (
3055+ location = f"file://{ tmp_path } " ,
3056+ last_column_id = 1 ,
3057+ format_version = 2 ,
3058+ schemas = [table_schema ],
3059+ partition_specs = [PartitionSpec ()],
3060+ )
3061+
3062+ task = WriteTask (
3063+ write_uuid = uuid .uuid4 (),
3064+ task_id = 0 ,
3065+ record_batches = arrow_data .to_batches (),
3066+ schema = table_schema ,
3067+ )
3068+
3069+ with patch ("pyiceberg.io.pyarrow.pq.read_metadata" , wraps = pq .read_metadata ) as mock_read_metadata :
3070+ data_files = list (write_file (io = PyArrowFileIO (), table_metadata = table_metadata , tasks = iter ([task ])))
3071+
3072+ assert mock_read_metadata .called
3073+ assert len (data_files ) == 1
3074+ assert data_files [0 ].record_count == 3
3075+
3076+
30483077def test__to_requested_schema_timestamps (
30493078 arrow_table_schema_with_all_timestamp_precisions : pa .Schema ,
30503079 arrow_table_with_all_timestamp_precisions : pa .Table ,
0 commit comments