#![allow(deprecated)]
use arrow::array::{ArrayRef, RecordBatch};
use arrow::datatypes::{Field, Schema, SchemaRef};
use datafusion_common::{ColumnStatistics, Result, not_impl_err};
use log::warn;
use std::fmt::Debug;
use std::sync::Arc;
#[deprecated(
since = "52.0.0",
note = "SchemaAdapter has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
pub type CastColumnFn = dyn Fn(&ArrayRef, &Field, &arrow::compute::CastOptions) -> Result<ArrayRef>
+ Send
+ Sync;
#[deprecated(
since = "52.0.0",
note = "SchemaAdapter has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
pub trait SchemaAdapterFactory: Debug + Send + Sync + 'static {
fn create(
&self,
projected_table_schema: SchemaRef,
table_schema: SchemaRef,
) -> Box<dyn SchemaAdapter>;
fn create_with_projected_schema(
&self,
projected_table_schema: SchemaRef,
) -> Box<dyn SchemaAdapter> {
self.create(Arc::clone(&projected_table_schema), projected_table_schema)
}
}
#[deprecated(
since = "52.0.0",
note = "SchemaAdapter has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
pub trait SchemaAdapter: Send + Sync {
fn map_column_index(&self, index: usize, file_schema: &Schema) -> Option<usize>;
fn map_schema(
&self,
file_schema: &Schema,
) -> Result<(Arc<dyn SchemaMapper>, Vec<usize>)>;
}
#[deprecated(
since = "52.0.0",
note = "SchemaMapper has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
pub trait SchemaMapper: Debug + Send + Sync {
fn map_batch(&self, batch: RecordBatch) -> Result<RecordBatch>;
fn map_column_statistics(
&self,
file_col_statistics: &[ColumnStatistics],
) -> Result<Vec<ColumnStatistics>>;
}
#[deprecated(
since = "52.0.0",
note = "DefaultSchemaAdapterFactory has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
#[derive(Clone, Debug, Default)]
pub struct DefaultSchemaAdapterFactory;
impl SchemaAdapterFactory for DefaultSchemaAdapterFactory {
fn create(
&self,
projected_table_schema: SchemaRef,
_table_schema: SchemaRef,
) -> Box<dyn SchemaAdapter> {
Box::new(DeprecatedSchemaAdapter {
_projected_table_schema: projected_table_schema,
})
}
}
impl DefaultSchemaAdapterFactory {
#[deprecated(
since = "52.0.0",
note = "DefaultSchemaAdapterFactory has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
pub fn from_schema(table_schema: SchemaRef) -> Box<dyn SchemaAdapter> {
warn!(
"DefaultSchemaAdapterFactory::from_schema is deprecated. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
);
Box::new(DeprecatedSchemaAdapter {
_projected_table_schema: table_schema,
})
}
}
struct DeprecatedSchemaAdapter {
_projected_table_schema: SchemaRef,
}
impl SchemaAdapter for DeprecatedSchemaAdapter {
fn map_column_index(&self, _index: usize, _file_schema: &Schema) -> Option<usize> {
None }
fn map_schema(
&self,
_file_schema: &Schema,
) -> Result<(Arc<dyn SchemaMapper>, Vec<usize>)> {
not_impl_err!(
"SchemaAdapter has been removed. Use PhysicalExprAdapterFactory instead. \
See upgrading.md for more details."
)
}
}
#[deprecated(
since = "52.0.0",
note = "SchemaMapping has been removed. Use PhysicalExprAdapterFactory instead. See upgrading.md for more details."
)]
#[derive(Debug)]
pub struct SchemaMapping {
_private: (),
}
impl SchemaMapper for SchemaMapping {
fn map_batch(&self, _batch: RecordBatch) -> Result<RecordBatch> {
not_impl_err!(
"SchemaMapping has been removed. Use PhysicalExprAdapterFactory instead. \
See upgrading.md for more details."
)
}
fn map_column_statistics(
&self,
_file_col_statistics: &[ColumnStatistics],
) -> Result<Vec<ColumnStatistics>> {
not_impl_err!(
"SchemaMapping has been removed. Use PhysicalExprAdapterFactory instead. \
See upgrading.md for more details."
)
}
}