kosiew commented on code in PR #27027:
URL: https://github.com/apache/datafusion/pull/27027#discussion_r4639460696


##########
docs/source/library-user-guide/upgrading/56.0.0.md:
##########
@@ -1498,3 +1498,17 @@ fn is_nullable(&self) -> bool {
 ```
 
 See [issue #18882](https://github.com/apache/datafusion/issues/18882) for 
details.
+
+### `ParquetSink`s created by `ParquetFormat` no longer retain written file 
metadata

Review Comment:
   Please move this note to upgrading/57.0.0.md when rebasing. Main already 
links the 57.0.0 guide.



##########
datafusion/datasource-parquet/src/sink.rs:
##########
@@ -119,10 +123,29 @@ impl ParquetSink {
         self
     }
 
+    /// Whether to keep the [`ParquetMetaData`] of every written file so that 
it
+    /// can be read back with [`Self::written`]. Defaults to `true`.
+    ///
+    /// The metadata carries every column chunk's statistics and page indexes
+    /// and is held until the sink is dropped, so a write that produces many
+    /// files pays for it in memory. Turn it off when nothing reads
+    /// [`Self::written`], as the sinks `ParquetFormat` creates for `COPY` and
+    /// `INSERT` do.
+    pub fn with_retain_written_metadata(mut self, retain: bool) -> Self {

Review Comment:
   Could we document that protobuf serialization does not preserve this 
opt-out? Decoding constructs a new ParquetSink with retention enabled, 
including on distributed executors. Please clarify this in the upgrade note.



##########
datafusion/datasource-parquet/src/file_format.rs:
##########
@@ -710,7 +710,11 @@ impl FileFormat for ParquetFormat {
 
         let sink = Arc::new(
             ParquetSink::new(conf, self.options.clone())
-                .with_sorting_columns(sorting_columns),
+                .with_sorting_columns(sorting_columns)
+                // Nothing on this path reads `ParquetSink::written`, and 
keeping
+                // every file's metadata would grow memory with the number of
+                // files a statement writes.
+                .with_retain_written_metadata(false),

Review Comment:
   The current test explicitly disables retention, so it cannot catch a 
regression here. Please add a multi-file COPY test using the planned sink, 
verifying output files, row counts, and empty written() metadata.



##########
datafusion/datasource-parquet/src/sink.rs:
##########
@@ -391,6 +409,36 @@ impl FileSink for ParquetSink {
     }
 }
 
+/// Accounts for a file the sink has finished writing: returns its row count
+/// and the sum of its compressed row group sizes for the `rows_written` and
+/// `bytes_written` metrics, and stores its [`ParquetMetaData`] in `written`
+/// when the sink retains metadata.
+///
+/// Runs inside the writer task so that, with retention off, the metadata is
+/// dropped as soon as the file is closed and the sink holds no per-file state.

Review Comment:
   Nit: Please say metadata is dropped at file close instead. JoinSet still 
retains a task entry and two counts per completed file until drained.



##########
datafusion/datasource-parquet/src/file_format.rs:
##########
@@ -710,7 +710,11 @@ impl FileFormat for ParquetFormat {
 
         let sink = Arc::new(
             ParquetSink::new(conf, self.options.clone())
-                .with_sorting_columns(sorting_columns),
+                .with_sorting_columns(sorting_columns)
+                // Nothing on this path reads `ParquetSink::written`, and 
keeping
+                // every file's metadata would grow memory with the number of
+                // files a statement writes.
+                .with_retain_written_metadata(false),

Review Comment:
   The current test explicitly disables retention, so it cannot catch a 
regression here. Please add a multi-file COPY test using the planned sink, 
verifying output files, row counts, and empty written() metadata.



##########
docs/source/library-user-guide/upgrading/56.0.0.md:
##########
@@ -1498,3 +1498,17 @@ fn is_nullable(&self) -> bool {
 ```
 
 See [issue #18882](https://github.com/apache/datafusion/issues/18882) for 
details.
+
+### `ParquetSink`s created by `ParquetFormat` no longer retain written file 
metadata

Review Comment:
   Please move this note to upgrading/57.0.0.md when rebasing. Main already 
links the 57.0.0 guide.



##########
datafusion/datasource-parquet/src/sink.rs:
##########
@@ -391,6 +409,36 @@ impl FileSink for ParquetSink {
     }
 }
 
+/// Accounts for a file the sink has finished writing: returns its row count
+/// and the sum of its compressed row group sizes for the `rows_written` and
+/// `bytes_written` metrics, and stores its [`ParquetMetaData`] in `written`
+/// when the sink retains metadata.
+///
+/// Runs inside the writer task so that, with retention off, the metadata is
+/// dropped as soon as the file is closed and the sink holds no per-file state.

Review Comment:
   Nit: Please say metadata is dropped at file close instead. JoinSet still 
retains a task entry and two counts per completed file until drained.



##########
datafusion/datasource-parquet/src/sink.rs:
##########
@@ -119,10 +123,29 @@ impl ParquetSink {
         self
     }
 
+    /// Whether to keep the [`ParquetMetaData`] of every written file so that 
it
+    /// can be read back with [`Self::written`]. Defaults to `true`.
+    ///
+    /// The metadata carries every column chunk's statistics and page indexes
+    /// and is held until the sink is dropped, so a write that produces many
+    /// files pays for it in memory. Turn it off when nothing reads
+    /// [`Self::written`], as the sinks `ParquetFormat` creates for `COPY` and
+    /// `INSERT` do.
+    pub fn with_retain_written_metadata(mut self, retain: bool) -> Self {

Review Comment:
   Could we document that protobuf serialization does not preserve this 
opt-out? Decoding constructs a new ParquetSink with retention enabled, 
including on distributed executors. Please clarify this in the upgrade note.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to