jorisvandenbossche commented on code in PR #14574: URL: https://github.com/apache/arrow/pull/14574#discussion_r1019977209
########## python/pyarrow/parquet/core.py: ########## @@ -3423,16 +3427,22 @@ def write_metadata(schema, where, metadata_collector=None, **kwargs): ... table.schema, 'dataset_metadata/_metadata', ... metadata_collector=metadata_collector) """ - writer = ParquetWriter(where, schema, **kwargs) + filesystem, where = _resolve_filesystem_and_path(where, filesystem) + + writer = ParquetWriter(where, schema, filesystem, **kwargs) writer.close() if metadata_collector is not None: # ParquetWriter doesn't expose the metadata until it's written. Write # it and read it again. - metadata = read_metadata(where) + metadata = read_metadata(where, filesystem=filesystem) for m in metadata_collector: metadata.append_row_groups(m) - metadata.write_metadata_file(where) + file_ctx = nullcontext() + if filesystem is not None: + file_ctx = where = filesystem.open_output_stream(where) + with file_ctx: + metadata.write_metadata_file(where) Review Comment: ```suggestion if filesystem is not None: with filesystem.open_output_stream(where) as dest: metadata.write_metadata_file(dest) else: metadata.write_metadata_file(where) ``` Just a nit, but to see the diff, this is just as many lines of code, and even less characters, while trying to be less "smart" (and IMO easier to read) -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org