@@ -197,7 +197,7 @@ impl ListingTableConfig {
197
197
/// Set the schema policy for the [`ListingTable`]
198
198
pub fn with_schema_policy ( self , schema_policy : SchemaPolicy ) -> Self {
199
199
// If we have a file_schema, enforce Fixed policy with that schema
200
- if let Some ( schema) = & self . file_schema {
200
+ if let Some ( schema) = & self . file_schema . clone ( ) {
201
201
match schema_policy {
202
202
SchemaPolicy :: Fixed ( _) => {
203
203
// Use provided Fixed policy with our schema
@@ -234,7 +234,7 @@ impl ListingTableConfig {
234
234
235
235
/// Ensures that if a file schema is provided, the schema policy is set to Fixed
236
236
fn ensure_schema_policy ( self ) -> Self {
237
- if let Some ( schema) = & self . file_schema {
237
+ if let Some ( schema) = & self . file_schema . clone ( ) {
238
238
match self . schema_policy {
239
239
Some ( SchemaPolicy :: Fixed ( _) ) => {
240
240
// Already have a Fixed policy, but make sure it's using our schema
@@ -367,28 +367,29 @@ impl ListingTableConfig {
367
367
} ) ;
368
368
}
369
369
370
- let schema = match self . schema_policy . unwrap_or ( SchemaPolicy :: First ) {
371
- // For Fixed policy, we already have a schema
372
- SchemaPolicy :: Fixed ( schema) => schema,
373
- // For Merge policy, we infer from all files (current behavior)
374
- SchemaPolicy :: Merge => {
375
- if let Some ( url) = self . table_paths . first ( ) {
376
- options. infer_schema ( state, url) . await ?
377
- } else {
378
- Arc :: new ( Schema :: empty ( ) )
370
+ let schema =
371
+ match self . schema_policy . clone ( ) . unwrap_or ( SchemaPolicy :: First ) {
372
+ // For Fixed policy, we already have a schema
373
+ SchemaPolicy :: Fixed ( schema) => schema,
374
+ // For Merge policy, we infer from all files (current behavior)
375
+ SchemaPolicy :: Merge => {
376
+ if let Some ( url) = self . table_paths . first ( ) {
377
+ options. infer_schema ( state, url) . await ?
378
+ } else {
379
+ Arc :: new ( Schema :: empty ( ) )
380
+ }
379
381
}
380
- }
381
- // For First policy, we only read schema from the first file
382
- SchemaPolicy :: First => {
383
- if let Some ( url ) = self . table_paths . first ( ) {
384
- // TODO: Implement a more efficient version that only looks at the first file
385
- // For now, we'll use the same implementation as Merge
386
- options . infer_schema ( state , url ) . await ?
387
- } else {
388
- Arc :: new ( Schema :: empty ( ) )
382
+ // For First policy, we only read schema from the first file
383
+ SchemaPolicy :: First => {
384
+ if let Some ( url ) = self . table_paths . first ( ) {
385
+ // TODO: Implement a more efficient version that only looks at the first file
386
+ // For now, we'll use the same implementation as Merge
387
+ options . infer_schema ( state , url ) . await ?
388
+ } else {
389
+ Arc :: new ( Schema :: empty ( ) )
390
+ }
389
391
}
390
- }
391
- } ;
392
+ } ;
392
393
393
394
// When we infer a schema, keep the current policy
394
395
Ok ( Self {
0 commit comments