@@ -24,7 +24,7 @@ use crate::scan::log_replay::{
2424 BASE_ROW_ID_NAME , DEFAULT_ROW_COMMIT_VERSION_NAME , FILE_CONSTANT_VALUES_NAME , TAGS_NAME ,
2525} ;
2626use crate :: scan:: scan_row_schema;
27- use crate :: schema:: { ArrayType , MapType , SchemaRef , StructField , StructType } ;
27+ use crate :: schema:: { ArrayType , MapType , SchemaRef , StructField , StructType , StructTypeBuilder } ;
2828use crate :: snapshot:: SnapshotRef ;
2929use crate :: utils:: { current_time_ms, require} ;
3030use crate :: {
@@ -66,9 +66,9 @@ pub(crate) static BASE_ADD_FILES_SCHEMA: LazyLock<SchemaRef> = LazyLock::new(||
6666 DataType :: struct_type_unchecked ( vec ! [ StructField :: nullable( "numRecords" , DataType :: LONG ) ] ) ,
6767 ) ;
6868
69- Arc :: new ( StructType :: new_unchecked (
70- mandatory_add_file_schema ( ) . fields ( ) . cloned ( ) . chain ( [ stats] ) ,
71- ) )
69+ StructTypeBuilder :: from_schema ( mandatory_add_file_schema ( ) )
70+ . add_field ( stats)
71+ . build_arc_unchecked ( )
7272} ) ;
7373
7474static DATA_CHANGE_COLUMN : LazyLock < StructField > =
@@ -86,30 +86,28 @@ static ADD_FILES_SCHEMA_WITH_DATA_CHANGE: LazyLock<SchemaRef> = LazyLock::new(||
8686 Arc :: new ( StructType :: new_unchecked ( fields. into_iter ( ) . cloned ( ) ) )
8787} ) ;
8888
89- // NOTE: The following two methods are a workaround for the fact that we do not have a proper SchemaBuilder yet.
90- // See https://github.com/delta-io/delta-kernel-rs/issues/1284
9189/// Extend a schema with a statistics column and return a new SchemaRef.
9290///
9391/// The stats column is of type string as required by the spec.
9492///
9593/// Note that this method is only useful to extend an Add action schema.
9694fn with_stats_col ( schema : & SchemaRef ) -> SchemaRef {
97- let fields = schema
98- . fields ( )
99- . cloned ( )
100- . chain ( [ StructField :: nullable ( "stats" , DataType :: STRING ) ] ) ;
101- Arc :: new ( StructType :: new_unchecked ( fields) )
95+ StructTypeBuilder :: from_schema ( schema)
96+ . add_field ( StructField :: nullable ( "stats" , DataType :: STRING ) )
97+ . build_arc_unchecked ( )
10298}
10399
104100/// Extend a schema with row tracking columns and return a new SchemaRef.
105101///
106102/// Note that this method is only useful to extend an Add action schema.
107103fn with_row_tracking_cols ( schema : & SchemaRef ) -> SchemaRef {
108- let fields = schema. fields ( ) . cloned ( ) . chain ( [
109- StructField :: nullable ( "baseRowId" , DataType :: LONG ) ,
110- StructField :: nullable ( "defaultRowCommitVersion" , DataType :: LONG ) ,
111- ] ) ;
112- Arc :: new ( StructType :: new_unchecked ( fields) )
104+ StructTypeBuilder :: from_schema ( schema)
105+ . add_field ( StructField :: nullable ( "baseRowId" , DataType :: LONG ) )
106+ . add_field ( StructField :: nullable (
107+ "defaultRowCommitVersion" ,
108+ DataType :: LONG ,
109+ ) )
110+ . build_arc_unchecked ( )
113111}
114112
115113/// A transaction represents an in-progress write to a table. After creating a transaction, changes
0 commit comments