Skip to content

Commit

Permalink
chore: restructure to avoid need to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
timvw committed Jan 8, 2025
1 parent d78cbed commit 5bd9c8c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions datafusion/core/src/datasource/listing/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@ impl ListingTableConfig {

let mut format_options = HashMap::new();

let listing_file_extension =
if let Some(compression_type) = maybe_compression_type {
format_options
.insert("format.compression".to_string(), compression_type.clone());
format!("{}.{}", &file_extension, &compression_type)
} else {
file_extension.clone()
};

let file_format = state
.get_file_format_factory(&file_extension)
.ok_or(config_datafusion_err!(
"No file_format found with extension {file_extension}"
))?
.create(state, &format_options)?;

let listing_file_extension =
if let Some(compression_type) = maybe_compression_type {
let file_extension = format!("{}.{}", &file_extension, &compression_type);
format_options.insert("format.compression".to_string(), compression_type);
file_extension
} else {
file_extension
};

let listing_options = ListingOptions::new(file_format)
.with_file_extension(listing_file_extension)
.with_target_partitions(state.config().target_partitions());
Expand Down

0 comments on commit 5bd9c8c

Please sign in to comment.