Skip to content

Commit

Permalink
fix && remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
ZENOTME committed Dec 4, 2024
1 parent ecfe66e commit e1836e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
4 changes: 0 additions & 4 deletions crates/iceberg/src/writer/base_writer/data_file_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ impl<B: FileWriterBuilder> CurrentWriterStatus for DataFileWriter<B> {
fn current_written_size(&self) -> usize {
self.inner_writer.as_ref().unwrap().current_written_size()
}

fn current_schema(&self) -> SchemaRef {
self.inner_writer.as_ref().unwrap().current_schema()
}
}

#[cfg(test)]
Expand Down
27 changes: 15 additions & 12 deletions crates/iceberg/src/writer/base_writer/equality_delete_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,21 +571,22 @@ mod test {
.build()
.unwrap(),
);
let equality_ids = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
let config = EqualityDeleteWriterConfig::new(equality_ids, schema.clone(), None).unwrap();
let delete_arrow_schema = config.projected_arrow_schema_ref().clone();
let delete_schema = arrow_schema_to_schema(&delete_arrow_schema).unwrap();

let pb = ParquetWriterBuilder::new(
WriterProperties::builder().build(),
Arc::new(delete_schema),
file_io.clone(),
location_gen,
file_name_gen,
);
let mut equality_delete_writer = EqualityDeleteFileWriterBuilder::new(pb)
.build(config)
.await?;
let mut equality_delete_writer = EqualityDeleteFileWriterBuilder::new(
pb,
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
schema.clone(),
None,
)
.unwrap()
.build()
.await?;

// prepare data
let col0 = Arc::new(BooleanArray::from(vec![
Expand Down Expand Up @@ -662,10 +663,12 @@ mod test {
Some(b""),
Some(b"zzzz"),
])) as ArrayRef;
let to_write = RecordBatch::try_new(delete_arrow_schema.clone(), vec![
col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13,
])
.unwrap();
let to_write =
RecordBatch::try_new(Arc::new(schema_to_arrow_schema(&schema).unwrap()), vec![
col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12,
col13,
])
.unwrap();
equality_delete_writer.write(to_write.clone()).await?;
let res = equality_delete_writer.close().await?;
assert_eq!(res.len(), 1);
Expand Down
4 changes: 0 additions & 4 deletions crates/iceberg/src/writer/file_writer/parquet_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,6 @@ impl CurrentWriterStatus for ParquetWriter {
fn current_written_size(&self) -> usize {
self.written_size.load(std::sync::atomic::Ordering::Relaxed) as usize
}

fn current_schema(&self) -> SchemaRef {
self.schema.clone()
}
}

/// AsyncFileWriter is a wrapper of FileWrite to make it compatible with tokio::io::AsyncWrite.
Expand Down
4 changes: 1 addition & 3 deletions crates/iceberg/src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub mod file_writer;

use arrow_array::RecordBatch;

use crate::spec::{DataFile, SchemaRef};
use crate::spec::DataFile;
use crate::Result;

type DefaultInput = RecordBatch;
Expand Down Expand Up @@ -88,8 +88,6 @@ pub trait CurrentWriterStatus {
fn current_row_num(&self) -> usize;
/// Get the current file written size.
fn current_written_size(&self) -> usize;
/// Get the schema of the current file.
fn current_schema(&self) -> SchemaRef;
}

#[cfg(test)]
Expand Down

0 comments on commit e1836e1

Please sign in to comment.