Skip to content

Commit 00fd661

Browse files
committed
Fix borrow errors
1 parent a3e799e commit 00fd661

File tree

1 file changed

+23
-22
lines changed
  • datafusion/core/src/datasource/listing

1 file changed

+23
-22
lines changed

datafusion/core/src/datasource/listing/table.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl ListingTableConfig {
197197
/// Set the schema policy for the [`ListingTable`]
198198
pub fn with_schema_policy(self, schema_policy: SchemaPolicy) -> Self {
199199
// 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() {
201201
match schema_policy {
202202
SchemaPolicy::Fixed(_) => {
203203
// Use provided Fixed policy with our schema
@@ -234,7 +234,7 @@ impl ListingTableConfig {
234234

235235
/// Ensures that if a file schema is provided, the schema policy is set to Fixed
236236
fn ensure_schema_policy(self) -> Self {
237-
if let Some(schema) = &self.file_schema {
237+
if let Some(schema) = &self.file_schema.clone() {
238238
match self.schema_policy {
239239
Some(SchemaPolicy::Fixed(_)) => {
240240
// Already have a Fixed policy, but make sure it's using our schema
@@ -367,28 +367,29 @@ impl ListingTableConfig {
367367
});
368368
}
369369

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+
}
379381
}
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+
}
389391
}
390-
}
391-
};
392+
};
392393

393394
// When we infer a schema, keep the current policy
394395
Ok(Self {

0 commit comments

Comments
 (0)