@@ -19,7 +19,7 @@ use crate::schema::{ArrayType, ColumnNamesAndTypes, DataType, MapType, SchemaRef
19
19
use crate :: table_changes:: scan_file:: { cdf_scan_row_expression, cdf_scan_row_schema} ;
20
20
use crate :: table_configuration:: TableConfiguration ;
21
21
use crate :: utils:: require;
22
- use crate :: { DeltaResult , Engine , EngineData , Error , ExpressionRef , RowVisitor } ;
22
+ use crate :: { table , DeltaResult , Engine , EngineData , Error , ExpressionRef , RowVisitor } ;
23
23
24
24
use itertools:: Itertools ;
25
25
@@ -181,30 +181,31 @@ fn process_cdf_commit(
181
181
protocol : None ,
182
182
metadata : None ,
183
183
} ;
184
- visitor. visit_rows_of ( actions. as_ref ( ) ) ?;
185
184
186
- //table_configuration.with_protocol(visitor.protocol)?;
187
- //if let Some(metadata) = visitor.metadata {
188
- // table_configuration.with_metadata(metadata)?;
189
- // // Currently, schema compatibility is defined as having equal schema types. In the
190
- // // future, more permisive schema evolution will be supported.
191
- // // See: https://github.com/delta-io/delta-kernel-rs/issues/523
192
- // require!(
193
- // table_schema.as_ref() == table_configuration.schema(),
194
- // Error::change_data_feed_incompatible_schema(
195
- // table_schema,
196
- // table_configuration.schema()
197
- // )
198
- // );
199
- //}
200
- if !table_configuration. is_cdf_read_supported ( ) {
201
- return Err ( Error :: change_data_feed_unsupported ( commit_file. version ) ) ;
185
+ visitor. visit_rows_of ( actions. as_ref ( ) ) ?;
186
+ let has_metadata = visitor. metadata . is_some ( ) ;
187
+ match ( visitor. protocol , visitor. metadata ) {
188
+ ( None , None ) => { }
189
+ ( p, m) => {
190
+ let p = p. unwrap_or_else ( || table_configuration. protocol ( ) . clone ( ) ) ;
191
+ let m = m. unwrap_or_else ( || table_configuration. metadata ( ) . clone ( ) ) ;
192
+ * table_configuration = TableConfiguration :: try_new ( m, p) ?;
193
+ if !table_configuration. is_cdf_read_supported ( ) {
194
+ return Err ( Error :: change_data_feed_unsupported ( commit_file. version ) ) ;
195
+ }
196
+ }
197
+ }
198
+ if has_metadata {
199
+ require ! (
200
+ table_schema. as_ref( ) == table_configuration. schema( ) ,
201
+ Error :: change_data_feed_incompatible_schema(
202
+ table_schema,
203
+ table_configuration. schema( )
204
+ )
205
+ ) ;
202
206
}
203
207
}
204
208
205
- table_configuration
206
- . can_read_cdf ( )
207
- . map_err ( |_| Error :: change_data_feed_unsupported ( commit_file. version ) ) ?;
208
209
// We resolve the remove deletion vector map after visiting the entire commit.
209
210
if has_cdc_action {
210
211
remove_dvs. clear ( ) ;
0 commit comments