diff --git a/src/write/file.rs b/src/write/file.rs index 6a3309350..36c4560ef 100644 --- a/src/write/file.rs +++ b/src/write/file.rs @@ -119,9 +119,8 @@ impl FileWriter { Ok(()) } - /// Writes the footer of the parquet file. Returns the total size of the file and the - /// underlying writer. - pub fn end(mut self, key_value_metadata: Option>) -> Result<(u64, W)> { + /// Writes the footer of the parquet file. Returns the total size of the file. + pub fn end(&mut self, key_value_metadata: Option>) -> Result { // compute file stats let num_rows = self.row_groups.iter().map(|group| group.num_rows).sum(); @@ -166,18 +165,23 @@ impl FileWriter { let metadata = FileMetaData::new( self.options.version.into(), - self.schema.into_thrift(), + self.schema.clone().into_thrift(), num_rows, - self.row_groups, + self.row_groups.clone(), key_value_metadata, - self.created_by, + self.created_by.clone(), None, None, None, ); let len = end_file(&mut self.writer, metadata)?; - Ok((self.offset + len, self.writer)) + Ok(self.offset + len) + } + + /// Returns the underlying writer. + pub fn into_inner(self) -> W { + self.writer } } diff --git a/tests/it/write/indexes.rs b/tests/it/write/indexes.rs index a1f5216b1..e28e5d1d2 100644 --- a/tests/it/write/indexes.rs +++ b/tests/it/write/indexes.rs @@ -53,9 +53,9 @@ fn write_file() -> Result> { writer.start()?; writer.write(DynIter::new(columns))?; - let writer = writer.end(None)?.1; + writer.end(None)?; - Ok(writer.into_inner()) + Ok(writer.into_inner().into_inner()) } #[test] diff --git a/tests/it/write/mod.rs b/tests/it/write/mod.rs index 5d1570f46..f7c3d0ab7 100644 --- a/tests/it/write/mod.rs +++ b/tests/it/write/mod.rs @@ -92,9 +92,9 @@ fn test_column(column: &str, compression: Compression) -> Result<()> { writer.start()?; writer.write(DynIter::new(columns))?; - let writer = writer.end(None)?.1; + writer.end(None)?; - let data = writer.into_inner(); + let data = writer.into_inner().into_inner(); let (result, statistics) = read_column(&mut Cursor::new(data))?; assert_eq!(array, result); @@ -213,9 +213,9 @@ fn basic() -> Result<()> { writer.start()?; writer.write(DynIter::new(columns))?; - let writer = writer.end(None)?.1; + writer.end(None)?; - let data = writer.into_inner(); + let data = writer.into_inner().into_inner(); let mut reader = Cursor::new(data); let metadata = read_metadata(&mut reader)?;