16
16
// under the License.
17
17
18
18
//! 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
+
19
24
use std:: future:: Future ;
20
25
use std:: pin:: Pin ;
21
26
use std:: sync:: Arc ;
@@ -26,29 +31,30 @@ use arrow_array::RecordBatch;
26
31
use once_cell:: sync:: Lazy ;
27
32
28
33
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
+ } ;
30
37
use crate :: writer:: file_writer:: { FileWriter , FileWriterBuilder } ;
31
38
use crate :: writer:: { IcebergWriter , IcebergWriterBuilder } ;
32
39
use crate :: { Error , ErrorKind , Result } ;
33
40
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
+ } ) ;
38
55
static POSITION_DELETE_SCHEMA : Lazy < Schema > = Lazy :: new ( || {
39
56
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( ) ] )
52
58
. build ( )
53
59
. unwrap ( )
54
60
} ) ;
0 commit comments