Skip to content

Commit 8b0e2e1

Browse files
committed
refactor: simplify file compression type parsing in PySessionContext
1 parent bcc4f81 commit 8b0e2e1

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/context.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,10 @@ impl PySessionContext {
756756
let delimiter_byte = delimiter_bytes[0];
757757

758758
// Validate file_compression_type synchronously before async call
759-
if let Some(compression_type) = &file_compression_type {
760-
// Return Python error directly instead of wrapping it in PyDataFusionError to match test expectations
761-
if let Err(err) = parse_file_compression_type(Some(compression_type.clone())) {
762-
return Err(PyDataFusionError::PythonError(err));
763-
}
764-
}
759+
let fct = match parse_file_compression_type(file_compression_type.clone()) {
760+
Ok(compression) => compression,
761+
Err(err) => return Err(PyDataFusionError::PythonError(err)),
762+
};
765763

766764
// Clone all string references to create owned values
767765
let file_extension_owned = file_extension.to_string();
@@ -782,10 +780,7 @@ impl PySessionContext {
782780
.delimiter(delimiter_byte)
783781
.schema_infer_max_records(schema_infer_max_records)
784782
.file_extension(&file_extension_owned)
785-
.file_compression_type(
786-
parse_file_compression_type(file_compression_type.clone())
787-
.map_err(py_err_to_datafusion_err)?,
788-
);
783+
.file_compression_type(compression);
789784

790785
// Use owned schema if provided
791786
if let Some(s) = &schema_owned {
@@ -808,10 +803,7 @@ impl PySessionContext {
808803
.delimiter(delimiter_byte)
809804
.schema_infer_max_records(schema_infer_max_records)
810805
.file_extension(&file_extension_owned)
811-
.file_compression_type(
812-
parse_file_compression_type(file_compression_type.clone())
813-
.map_err(py_err_to_datafusion_err)?,
814-
);
806+
.file_compression_type(compression);
815807

816808
// Use owned schema if provided
817809
if let Some(s) = &schema_owned {

0 commit comments

Comments
 (0)