Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine: refine interface of ManifestWriter #738

Merged
merged 4 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 26 additions & 31 deletions crates/iceberg/src/io/object_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@ mod tests {
use super::*;
use crate::io::{FileIO, OutputFile};
use crate::spec::{
DataContentType, DataFileBuilder, DataFileFormat, FormatVersion, Literal, Manifest,
ManifestContentType, ManifestEntry, ManifestListWriter, ManifestMetadata, ManifestStatus,
ManifestWriter, Struct, TableMetadata,
DataContentType, DataFileBuilder, DataFileFormat, Literal, ManifestEntry,
ManifestListWriter, ManifestStatus, ManifestWriterBuilder, Struct, TableMetadata,
};
use crate::table::Table;
use crate::TableIdent;
Expand Down Expand Up @@ -264,37 +263,33 @@ mod tests {
let current_partition_spec = self.table.metadata().default_partition_spec();

// Write data files
let data_file_manifest = ManifestWriter::new(
let mut writer = ManifestWriterBuilder::new(
self.next_manifest_file(),
current_snapshot.snapshot_id(),
Some(current_snapshot.snapshot_id()),
vec![],
current_schema.clone(),
current_partition_spec.as_ref().clone(),
)
.write(Manifest::new(
ManifestMetadata::builder()
.schema(current_schema.clone())
.content(ManifestContentType::Data)
.format_version(FormatVersion::V2)
.partition_spec((**current_partition_spec).clone())
.schema_id(current_schema.schema_id())
.build(),
vec![ManifestEntry::builder()
.status(ManifestStatus::Added)
.data_file(
DataFileBuilder::default()
.content(DataContentType::Data)
.file_path(format!("{}/1.parquet", &self.table_location))
.file_format(DataFileFormat::Parquet)
.file_size_in_bytes(100)
.record_count(1)
.partition(Struct::from_iter([Some(Literal::long(100))]))
.key_metadata(None)
.build()
.unwrap(),
)
.build()],
))
.await
.unwrap();
.build_v2_data();
writer
.add_entry(
ManifestEntry::builder()
.status(ManifestStatus::Added)
.data_file(
DataFileBuilder::default()
.content(DataContentType::Data)
.file_path(format!("{}/1.parquet", &self.table_location))
.file_format(DataFileFormat::Parquet)
.file_size_in_bytes(100)
.record_count(1)
.partition(Struct::from_iter([Some(Literal::long(100))]))
.build()
.unwrap(),
)
.build(),
)
.unwrap();
let data_file_manifest = writer.write_manifest_file().await.unwrap();

// Write to manifest list
let mut manifest_list_write = ManifestListWriter::v2(
Expand Down
39 changes: 21 additions & 18 deletions crates/iceberg/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,9 @@ pub mod tests {
use crate::io::{FileIO, OutputFile};
use crate::scan::FileScanTask;
use crate::spec::{
DataContentType, DataFileBuilder, DataFileFormat, Datum, FormatVersion, Literal, Manifest,
ManifestContentType, ManifestEntry, ManifestListWriter, ManifestMetadata, ManifestStatus,
ManifestWriter, NestedField, PrimitiveType, Schema, Struct, TableMetadata, Type,
DataContentType, DataFileBuilder, DataFileFormat, Datum, Literal, ManifestEntry,
ManifestListWriter, ManifestStatus, ManifestWriterBuilder, NestedField, PrimitiveType,
Schema, Struct, TableMetadata, Type,
};
use crate::table::Table;
use crate::TableIdent;
Expand Down Expand Up @@ -1059,20 +1059,16 @@ pub mod tests {
let current_partition_spec = self.table.metadata().default_partition_spec();

// Write data files
let data_file_manifest = ManifestWriter::new(
let mut writer = ManifestWriterBuilder::new(
self.next_manifest_file(),
current_snapshot.snapshot_id(),
Some(current_snapshot.snapshot_id()),
vec![],
current_schema.clone(),
current_partition_spec.as_ref().clone(),
)
.write(Manifest::new(
ManifestMetadata::builder()
.schema(current_schema.clone())
.content(ManifestContentType::Data)
.format_version(FormatVersion::V2)
.partition_spec((**current_partition_spec).clone())
.schema_id(current_schema.schema_id())
.build(),
vec![
.build_v2_data();
writer
.add_entry(
ManifestEntry::builder()
.status(ManifestStatus::Added)
.data_file(
Expand All @@ -1088,6 +1084,10 @@ pub mod tests {
.unwrap(),
)
.build(),
)
.unwrap();
writer
.add_delete_entry(
ManifestEntry::builder()
.status(ManifestStatus::Deleted)
.snapshot_id(parent_snapshot.snapshot_id())
Expand All @@ -1105,6 +1105,10 @@ pub mod tests {
.unwrap(),
)
.build(),
)
.unwrap();
writer
.add_existing_entry(
ManifestEntry::builder()
.status(ManifestStatus::Existing)
.snapshot_id(parent_snapshot.snapshot_id())
Expand All @@ -1122,10 +1126,9 @@ pub mod tests {
.unwrap(),
)
.build(),
],
))
.await
.unwrap();
)
.unwrap();
let data_file_manifest = writer.write_manifest_file().await.unwrap();

// Write to manifest list
let mut manifest_list_write = ManifestListWriter::v2(
Expand Down
Loading
Loading