Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: Remove deprecated methods #9627

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
51 changes: 9 additions & 42 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ pub type DFSchemaRef = Arc<DFSchema>;
/// ```rust
/// use datafusion_common::{DFSchema, DFField};
/// use arrow_schema::Schema;
/// use std::collections::HashMap;
///
/// let df_schema = DFSchema::new(vec![
/// let df_schema = DFSchema::new_with_metadata(vec![
/// DFField::new_unqualified("c1", arrow::datatypes::DataType::Int32, false),
/// ]).unwrap();
/// ], HashMap::new()).unwrap();
/// let schema = Schema::from(df_schema);
/// assert_eq!(schema.fields().len(), 1);
/// ```
Expand All @@ -124,12 +125,6 @@ impl DFSchema {
}
}

#[deprecated(since = "7.0.0", note = "please use `new_with_metadata` instead")]
/// Create a new `DFSchema`
pub fn new(fields: Vec<DFField>) -> Result<Self> {
Self::new_with_metadata(fields, HashMap::new())
}

/// Create a new `DFSchema`
pub fn new_with_metadata(
fields: Vec<DFField>,
Expand Down Expand Up @@ -251,32 +246,6 @@ impl DFSchema {
&self.fields[i]
}

#[deprecated(since = "8.0.0", note = "please use `index_of_column_by_name` instead")]
/// Find the index of the column with the given unqualified name
pub fn index_of(&self, name: &str) -> Result<usize> {
for i in 0..self.fields.len() {
if self.fields[i].name() == name {
return Ok(i);
} else {
// Now that `index_of` is deprecated an error is thrown if
// a fully qualified field name is provided.
match &self.fields[i].qualifier {
Some(qualifier) => {
if (qualifier.to_string() + "." + self.fields[i].name()) == name {
return _plan_err!(
"Fully qualified field name '{name}' was supplied to `index_of` \
which is deprecated. Please use `index_of_column_by_name` instead"
);
}
}
None => (),
}
}
}

Err(unqualified_field_not_found(name, self))
}

pub fn index_of_column_by_name(
&self,
qualifier: Option<&TableReference>,
Expand Down Expand Up @@ -1146,13 +1115,10 @@ mod tests {
Ok(())
}

#[allow(deprecated)]
#[test]
fn helpful_error_messages() -> Result<()> {
let schema = DFSchema::try_from_qualified_schema("t1", &test_schema_1())?;
let expected_help = "Valid fields are t1.c0, t1.c1.";
// Pertinent message parts
let expected_err_msg = "Fully qualified field name 't1.c0'";
assert_contains!(
schema
.field_with_qualified_name(&TableReference::bare("x"), "y")
Expand All @@ -1167,11 +1133,12 @@ mod tests {
.to_string(),
expected_help
);
assert_contains!(schema.index_of("y").unwrap_err().to_string(), expected_help);
assert_contains!(
schema.index_of("t1.c0").unwrap_err().to_string(),
expected_err_msg
);
assert!(schema.index_of_column_by_name(None, "y").unwrap().is_none());
assert!(schema
.index_of_column_by_name(None, "t1.c0")
.unwrap()
.is_none());

Ok(())
}

Expand Down
10 changes: 0 additions & 10 deletions datafusion/core/src/dataframe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,16 +1001,6 @@ impl DataFrame {
Arc::new(DataFrameTableProvider { plan: self.plan })
}

/// Return the optimized logical plan represented by this DataFrame.
///
/// Note: This method should not be used outside testing, as it loses the snapshot
/// of the [`SessionState`] attached to this [`DataFrame`] and consequently subsequent
/// operations may take place against a different state
#[deprecated(since = "23.0.0", note = "Use DataFrame::into_optimized_plan")]
pub fn to_logical_plan(self) -> Result<LogicalPlan> {
self.into_optimized_plan()
}

/// Return a DataFrame with the explanation of its plan so far.
///
/// if `analyze` is specified, runs the plan and reports metrics
Expand Down
33 changes: 0 additions & 33 deletions datafusion/core/src/datasource/listing/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// specific language governing permissions and limitations
// under the License.

use std::fs;

use crate::datasource::object_store::ObjectStoreUrl;
use crate::execution::context::SessionState;
use datafusion_common::{DataFusionError, Result};
Expand Down Expand Up @@ -117,37 +115,6 @@ impl ListingTableUrl {
}
}

/// Get object store for specified input_url
/// if input_url is actually not a url, we assume it is a local file path
/// if we have a local path, create it if not exists so ListingTableUrl::parse works
#[deprecated(note = "Use parse")]
pub fn parse_create_local_if_not_exists(
s: impl AsRef<str>,
is_directory: bool,
) -> Result<Self> {
let s = s.as_ref();
let is_valid_url = Url::parse(s).is_ok();

match is_valid_url {
true => ListingTableUrl::parse(s),
false => {
let path = std::path::PathBuf::from(s);
if !path.exists() {
if is_directory {
fs::create_dir_all(path)?;
} else {
// ensure parent directory exists
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
fs::File::create(path)?;
}
}
ListingTableUrl::parse(s)
}
}
}

/// Creates a new [`ListingTableUrl`] interpreting `s` as a filesystem path
#[cfg(not(target_arch = "wasm32"))]
fn parse_path(s: &str) -> Result<Self> {
Expand Down
43 changes: 0 additions & 43 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,49 +1181,6 @@ impl SessionContext {
}
}

/// Returns the set of available tables in the default catalog and
/// schema.
///
/// Use [`table`] to get a specific table.
///
/// [`table`]: SessionContext::table
#[deprecated(
since = "23.0.0",
note = "Please use the catalog provider interface (`SessionContext::catalog`) to examine available catalogs, schemas, and tables"
)]
pub fn tables(&self) -> Result<HashSet<String>> {
Ok(self
.state
.read()
// a bare reference will always resolve to the default catalog and schema
.schema_for_ref(TableReference::Bare { table: "".into() })?
.table_names()
.iter()
.cloned()
.collect())
}

/// Optimizes the logical plan by applying optimizer rules.
#[deprecated(
since = "23.0.0",
note = "Use SessionState::optimize to ensure a consistent state for planning and execution"
)]
pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan> {
self.state.read().optimize(plan)
}

/// Creates a physical plan from a logical plan.
#[deprecated(
since = "23.0.0",
note = "Use SessionState::create_physical_plan or DataFrame::create_physical_plan to ensure a consistent state for planning and execution"
)]
pub async fn create_physical_plan(
&self,
logical_plan: &LogicalPlan,
) -> Result<Arc<dyn ExecutionPlan>> {
self.state().create_physical_plan(logical_plan).await
}

/// Get a new TaskContext to run in this session
pub fn task_ctx(&self) -> Arc<TaskContext> {
Arc::new(TaskContext::from(self))
Expand Down
16 changes: 2 additions & 14 deletions datafusion/execution/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ impl SessionConfig {
/// converted to strings.
///
/// Note that this method will eventually be deprecated and
/// replaced by [`config_options`].
/// replaced by [`options`].
///
/// [`config_options`]: Self::config_options
/// [`options`]: Self::options
pub fn to_props(&self) -> HashMap<String, String> {
let mut map = HashMap::new();
// copy configs from config_options
Expand All @@ -447,18 +447,6 @@ impl SessionConfig {
map
}

/// Return a handle to the configuration options.
#[deprecated(since = "21.0.0", note = "use options() instead")]
pub fn config_options(&self) -> &ConfigOptions {
&self.options
}

/// Return a mutable handle to the configuration options.
#[deprecated(since = "21.0.0", note = "use options_mut() instead")]
pub fn config_options_mut(&mut self) -> &mut ConfigOptions {
&mut self.options
}

/// Add extensions.
///
/// Extensions can be used to attach extra data to the session config -- e.g. tracing information or caches.
Expand Down
45 changes: 6 additions & 39 deletions datafusion/execution/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ use std::{
sync::Arc,
};

use datafusion_common::{
config::{ConfigOptions, Extensions},
plan_datafusion_err, DataFusionError, Result,
};
use datafusion_common::{plan_datafusion_err, DataFusionError, Result};
use datafusion_expr::{AggregateUDF, ScalarUDF, WindowUDF};

use crate::{
Expand Down Expand Up @@ -102,39 +99,6 @@ impl TaskContext {
}
}

/// Create a new task context instance, by first copying all
/// name/value pairs from `task_props` into a `SessionConfig`.
#[deprecated(
since = "21.0.0",
note = "Construct SessionConfig and call TaskContext::new() instead"
)]
pub fn try_new(
task_id: String,
session_id: String,
task_props: HashMap<String, String>,
scalar_functions: HashMap<String, Arc<ScalarUDF>>,
aggregate_functions: HashMap<String, Arc<AggregateUDF>>,
runtime: Arc<RuntimeEnv>,
extensions: Extensions,
) -> Result<Self> {
let mut config = ConfigOptions::new().with_extensions(extensions);
for (k, v) in task_props {
config.set(&k, &v)?;
}
let session_config = SessionConfig::from(config);
let window_functions = HashMap::new();

Ok(Self::new(
Some(task_id),
session_id,
session_config,
scalar_functions,
aggregate_functions,
window_functions,
runtime,
))
}

/// Return the SessionConfig associated with this [TaskContext]
pub fn session_config(&self) -> &SessionConfig {
&self.session_config
Expand All @@ -160,7 +124,7 @@ impl TaskContext {
self.runtime.clone()
}

/// Update the [`ConfigOptions`]
/// Update the [`SessionConfig`]
pub fn with_session_config(mut self, session_config: SessionConfig) -> Self {
self.session_config = session_config;
self
Expand Down Expand Up @@ -229,7 +193,10 @@ impl FunctionRegistry for TaskContext {
#[cfg(test)]
mod tests {
use super::*;
use datafusion_common::{config::ConfigExtension, extensions_options};
use datafusion_common::{
config::{ConfigExtension, ConfigOptions, Extensions},
extensions_options,
};

extensions_options! {
struct TestExtension {
Expand Down
22 changes: 0 additions & 22 deletions datafusion/expr/src/aggregate_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,6 @@ impl FromStr for AggregateFunction {
}
}

/// Returns the datatype of the aggregate function.
/// This is used to get the returned data type for aggregate expr.
#[deprecated(
since = "27.0.0",
note = "please use `AggregateFunction::return_type` instead"
)]
pub fn return_type(
fun: &AggregateFunction,
input_expr_types: &[DataType],
) -> Result<DataType> {
fun.return_type(input_expr_types)
}

impl AggregateFunction {
/// Returns the datatype of the aggregate function given its argument types
///
Expand Down Expand Up @@ -328,15 +315,6 @@ pub fn sum_type_of_avg(input_expr_types: &[DataType]) -> Result<DataType> {
avg_sum_type(&coerced_data_types[0])
}

/// the signatures supported by the function `fun`.
#[deprecated(
since = "27.0.0",
note = "please use `AggregateFunction::signature` instead"
)]
pub fn signature(fun: &AggregateFunction) -> Signature {
fun.signature()
}

impl AggregateFunction {
/// the signatures supported by the function `fun`.
pub fn signature(&self) -> Signature {
Expand Down
28 changes: 0 additions & 28 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,27 +703,6 @@ pub fn find_df_window_func(name: &str) -> Option<WindowFunctionDefinition> {
}
}

/// Returns the datatype of the window function
#[deprecated(
since = "27.0.0",
note = "please use `WindowFunction::return_type` instead"
)]
pub fn return_type(
fun: &WindowFunctionDefinition,
input_expr_types: &[DataType],
) -> Result<DataType> {
fun.return_type(input_expr_types)
}

/// the signatures supported by the function `fun`.
#[deprecated(
since = "27.0.0",
note = "please use `WindowFunction::signature` instead"
)]
pub fn signature(fun: &WindowFunctionDefinition) -> Signature {
fun.signature()
}

// Exists expression.
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Exists {
Expand Down Expand Up @@ -887,13 +866,6 @@ impl Expr {
create_name(self)
}

/// Returns the name of this expression as it should appear in a schema. This name
/// will not include any CAST expressions.
#[deprecated(since = "14.0.0", note = "please use `display_name` instead")]
pub fn name(&self) -> Result<String> {
self.display_name()
}

/// Returns a full and complete string representation of this expression.
pub fn canonical_name(&self) -> String {
format!("{self}")
Expand Down
Loading
Loading