Skip to content

Commit 3174b42

Browse files
author
ZENOTME
committed
refine
1 parent 256de49 commit 3174b42

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

crates/iceberg/src/writer/base_writer/position_delete_file_writer.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
// under the License.
1717

1818
//! Position delete file writer.
19+
//!
20+
//! This writer does not keep track of seen deletes and assumes all incoming records are ordered
21+
//! by file and position as required by the spec. If there is no external process to order the
22+
//! records, consider using SortingPositionDeleteWriter(WIP) instead.
23+
1924
use std::future::Future;
2025
use std::pin::Pin;
2126
use std::sync::Arc;
@@ -26,29 +31,30 @@ use arrow_array::RecordBatch;
2631
use once_cell::sync::Lazy;
2732

2833
use crate::arrow::schema_to_arrow_schema;
29-
use crate::spec::{DataContentType, DataFile, NestedField, PrimitiveType, Schema, Struct, Type};
34+
use crate::spec::{
35+
DataContentType, DataFile, NestedField, NestedFieldRef, PrimitiveType, Schema, Struct, Type,
36+
};
3037
use crate::writer::file_writer::{FileWriter, FileWriterBuilder};
3138
use crate::writer::{IcebergWriter, IcebergWriterBuilder};
3239
use crate::{Error, ErrorKind, Result};
3340

34-
const POS_DELETE_FIELD1_NAME: &str = "file_path";
35-
const POS_DELETE_FIELD1_ID: i32 = 2147483546;
36-
const POS_DELETE_FIELD2_NAME: &str = "pos";
37-
const POS_DELETE_FIELD2_ID: i32 = 2147483545;
41+
static DELETE_FILE_PATH: Lazy<NestedFieldRef> = Lazy::new(|| {
42+
Arc::new(NestedField::required(
43+
2147483546,
44+
"file_path",
45+
Type::Primitive(PrimitiveType::String),
46+
))
47+
});
48+
static DELETE_FILE_POS: Lazy<NestedFieldRef> = Lazy::new(|| {
49+
Arc::new(NestedField::required(
50+
2147483545,
51+
"pos",
52+
Type::Primitive(PrimitiveType::Long),
53+
))
54+
});
3855
static POSITION_DELETE_SCHEMA: Lazy<Schema> = Lazy::new(|| {
3956
Schema::builder()
40-
.with_fields(vec![
41-
Arc::new(NestedField::required(
42-
POS_DELETE_FIELD1_ID,
43-
POS_DELETE_FIELD1_NAME,
44-
Type::Primitive(PrimitiveType::String),
45-
)),
46-
Arc::new(NestedField::required(
47-
POS_DELETE_FIELD2_ID,
48-
POS_DELETE_FIELD2_NAME,
49-
Type::Primitive(PrimitiveType::Long),
50-
)),
51-
])
57+
.with_fields(vec![DELETE_FILE_PATH.clone(), DELETE_FILE_POS.clone()])
5258
.build()
5359
.unwrap()
5460
});

0 commit comments

Comments
 (0)