diff --git a/datafusion/datasource-parquet/src/file_format.rs b/datafusion/datasource-parquet/src/file_format.rs index 734ec6b536f6..e89cff2aaf7c 100644 --- a/datafusion/datasource-parquet/src/file_format.rs +++ b/datafusion/datasource-parquet/src/file_format.rs @@ -24,11 +24,12 @@ use std::sync::Arc; // Re-export so the historical `file_format::*` paths still resolve. #[expect(deprecated)] +pub use crate::schema_coercion::coerce_int96_to_resolution; pub use crate::schema_coercion::{ - Int96Coercer, apply_file_schema_type_coercions, coerce_file_schema_to_string_type, - coerce_file_schema_to_view_type, coerce_int96_to_resolution, - transform_binary_to_string, transform_schema_to_view, + Int96Coercer, apply_file_schema_type_coercions, transform_binary_to_string, + transform_schema_to_view, }; + pub use crate::sink::ParquetSink; use arrow::datatypes::{Fields, Schema, SchemaRef}; diff --git a/datafusion/datasource-parquet/src/mod.rs b/datafusion/datasource-parquet/src/mod.rs index 260d6ee471c8..250b36ad6d3c 100644 --- a/datafusion/datasource-parquet/src/mod.rs +++ b/datafusion/datasource-parquet/src/mod.rs @@ -55,10 +55,10 @@ pub use row_filter::build_row_filter; pub use row_filter::can_expr_be_pushed_down_with_schemas; pub use row_group_filter::RowGroupAccessPlanFilter; #[expect(deprecated)] +pub use schema_coercion::coerce_int96_to_resolution; pub use schema_coercion::{ - Int96Coercer, apply_file_schema_type_coercions, coerce_file_schema_to_string_type, - coerce_file_schema_to_view_type, coerce_int96_to_resolution, - transform_binary_to_string, transform_schema_to_view, + Int96Coercer, apply_file_schema_type_coercions, transform_binary_to_string, + transform_schema_to_view, }; pub use sink::ParquetSink; pub use virtual_column::ParquetVirtualColumn; diff --git a/datafusion/datasource-parquet/src/schema_coercion.rs b/datafusion/datasource-parquet/src/schema_coercion.rs index 4598bb525be3..30cd5d7e6594 100644 --- a/datafusion/datasource-parquet/src/schema_coercion.rs +++ b/datafusion/datasource-parquet/src/schema_coercion.rs @@ -418,118 +418,6 @@ fn coerce_int96_to_resolution_impl( Some(transformed_schema) } -/// Coerces the file schema if the table schema uses a view type. -#[deprecated( - since = "47.0.0", - note = "Use `apply_file_schema_type_coercions` instead" -)] -pub fn coerce_file_schema_to_view_type( - table_schema: &Schema, - file_schema: &Schema, -) -> Option { - let mut transform = false; - let table_fields: HashMap<_, _> = table_schema - .fields - .iter() - .map(|f| { - let dt = f.data_type(); - if dt.equals_datatype(&DataType::Utf8View) - || dt.equals_datatype(&DataType::BinaryView) - { - transform = true; - } - (f.name(), dt) - }) - .collect(); - - if !transform { - return None; - } - - let transformed_fields: Vec> = file_schema - .fields - .iter() - .map( - |field| match (table_fields.get(field.name()), field.data_type()) { - (Some(DataType::Utf8View), DataType::Utf8 | DataType::LargeUtf8) => { - field_with_new_type(field, DataType::Utf8View) - } - ( - Some(DataType::BinaryView), - DataType::Binary | DataType::LargeBinary, - ) => field_with_new_type(field, DataType::BinaryView), - _ => Arc::clone(field), - }, - ) - .collect(); - - Some(Schema::new_with_metadata( - transformed_fields, - file_schema.metadata.clone(), - )) -} - -/// If the table schema uses a string type, coerce the file schema to use a string type. -/// -/// See [`ParquetFormat::binary_as_string`](crate::file_format::ParquetFormat::binary_as_string) for details -#[deprecated( - since = "47.0.0", - note = "Use `apply_file_schema_type_coercions` instead" -)] -pub fn coerce_file_schema_to_string_type( - table_schema: &Schema, - file_schema: &Schema, -) -> Option { - let mut transform = false; - let table_fields: HashMap<_, _> = table_schema - .fields - .iter() - .map(|f| (f.name(), f.data_type())) - .collect(); - let transformed_fields: Vec> = file_schema - .fields - .iter() - .map( - |field| match (table_fields.get(field.name()), field.data_type()) { - // table schema uses string type, coerce the file schema to use string type - ( - Some(DataType::Utf8), - DataType::Binary | DataType::LargeBinary | DataType::BinaryView, - ) => { - transform = true; - field_with_new_type(field, DataType::Utf8) - } - // table schema uses large string type, coerce the file schema to use large string type - ( - Some(DataType::LargeUtf8), - DataType::Binary | DataType::LargeBinary | DataType::BinaryView, - ) => { - transform = true; - field_with_new_type(field, DataType::LargeUtf8) - } - // table schema uses string view type, coerce the file schema to use view type - ( - Some(DataType::Utf8View), - DataType::Binary | DataType::LargeBinary | DataType::BinaryView, - ) => { - transform = true; - field_with_new_type(field, DataType::Utf8View) - } - _ => Arc::clone(field), - }, - ) - .collect(); - - if !transform { - None - } else { - Some(Schema::new_with_metadata( - transformed_fields, - file_schema.metadata.clone(), - )) - } -} - /// Create a new field with the specified data type, copying the other /// properties from the input field fn field_with_new_type(field: &FieldRef, new_type: DataType) -> FieldRef {