Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions datafusion/datasource-parquet/src/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ use std::ops::Range;
use std::sync::Arc;

// Re-export so the historical `file_format::*` paths still resolve.
#[expect(deprecated)]
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,
Int96Coercer, apply_file_schema_type_coercions, coerce_int96_to_resolution,
transform_binary_to_string, transform_schema_to_view,
};
pub use crate::sink::ParquetSink;
Expand Down
4 changes: 1 addition & 3 deletions datafusion/datasource-parquet/src/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ pub use reader::*; // Expose so downstream crates can use it
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::{
Int96Coercer, apply_file_schema_type_coercions, coerce_file_schema_to_string_type,
coerce_file_schema_to_view_type, coerce_int96_to_resolution,
Int96Coercer, apply_file_schema_type_coercions, coerce_int96_to_resolution,
transform_binary_to_string, transform_schema_to_view,
};
pub use sink::ParquetSink;
Expand Down
112 changes: 0 additions & 112 deletions datafusion/datasource-parquet/src/schema_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Schema> {
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<Arc<Field>> = 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<Schema> {
let mut transform = false;
let table_fields: HashMap<_, _> = table_schema
.fields
.iter()
.map(|f| (f.name(), f.data_type()))
.collect();
let transformed_fields: Vec<Arc<Field>> = 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 {
Expand Down
Loading